How to handle conflicting @openzeppelin/contracts versions originating from npm packages

I currently import both @account-abstraction v0.6 and v0.7 in my hardhat project, using the following:

"@account-abstraction-06": "git+https://github.com/eth-infinitism/account-abstraction.git#v0.6.0",
"@account-abstraction-07": "git+https://github.com/eth-infinitism/account-abstraction.git#v0.7.0"

@account-abstraction-06 depends on "@openzeppelin/contracts": "^4.2.0",
and
@account-abstraction-07 depends on "@openzeppelin/contracts": "^5.0.0",

Both of these dependencies import OpenZeppelin contracts with the same base path, i.e., @openzeppelin/contracts .
This presents a problem because I cannot simply install both versions of the @openzeppelin/contracts without causing a conflict.
And I cannot use aliases as this would require modifying the source in @account-abstraction-06 and @account-abstraction-07

:1234: Code to reproduce

Create an empty hardhat project

npx hardhat init

add both these dependencies (use yarn)

"@account-abstraction-06": "git+https://github.com/eth-infinitism/account-abstraction.git#v0.6.0",
"@account-abstraction-07": "git+https://github.com/eth-infinitism/account-abstraction.git#v0.7.0",

add this import to Lock.sol
import "@account-abstraction-07/contracts/core/BasePaymaster.sol";
hardhat compile
Compilation will fail with the following error TypeError: Wrong argument count for modifier invocation: 1 arguments given but expected 0.