Collapse side menu items when group is hidden?

Hello, I wanted to know if it is all possible to have my menu items move up to fill the empty space left when a group in the menu is hidden?

basically i have it set where if a user position does not equal the level i want them to see on the side menu, the group is hidden, but it leaves an empty space between the other groups. I wanted to know if it is possible to have the other groups shift upwards when one is hidden to keep them all together and not disjointed

currently when a group is not hidden

currently when a group is hidden
cad help2

I couldn’t find a previous post on this topic