Hiding Submenus

I understand very well now how to hide/disable contextual menu commands, but…

Is there a way to hide a sub-menu title from appearing when the contents of the sub-menu itself are all hidden? I can’t seem to find a solution to this one.

It’s not an issue of functionality, but aesthetics. I’d rather the sub-menu not appear if nothing within it is currently available.

Not sure if this is relevant to finding the solution I seek, but I did notice that when just 1 of a given submenu’s items is active, and none of the parent-level items are (save the given sub-menu), that sole sub-menu item appears as if it is in the parent (no sub-menu title, pop-up arrow, etc) which is really useful in certain situations.

But how to hide a sub-menu entirely (not merely its contents)?

+1 to the ability to hide empty sub-menus