The way to solve the problem is making it a bad investment asset.
The best way to do it is to tax real estate progressively. The more you own, the higher percentage of its value you must pay every year.
That taxation scheme would make investors drop millions of houses on the market like a hot potato.
Prices would tank. This might cause issues with real estate as mortgage collateral. So that needs to be reformed first. Bank would need to be forced by law to accept swapping collateral for another of the same value. Regardless of the current price of the collateral and its replacement. They should also be forced to consider mortgage fully paid once they decide to end the loan and take posession of the collateral.
Also no bailouts. Banks are companies. Superpower of companies is that they can die. Let them.