The description of the mental prison spell reads:
you make the area immediately around the target’s space appear dangerous in some way. (XGtE, pg. 161)
And the spell’s 10d10 damage triggers when,
the target is moved out of the illusion...or reaches any part of its body through it.
It seems this can be interpreted to mean the illusion appears on all sides around the target and not necessarily above the target. Can a creature with immunity to restrained and a flying speed avoid the 10d10 damage by flying up and out of the illusion?
Here is a list of creatures with immunity to restrained and a flying speed.