Is there a method to program key commands to hide/unhide folders?

I am familiar with the track visibility configurations, but this is not what I am referring to.

I am asking about a method to control track visibility as if you were clicking the check-box next to a folder in the project window visibility panel.
I would like to use a key command to toggle individual folders on and off (hiding them/unhiding them in the project window).

Is there a method to do this? Is the “project logical editor” capable of this?

Just off the top of my head…

You could use the Project Logical Editor to select folder tracks based on their name (e.g. select a folder that has ‘1’ in the name, or ‘2’ in the name etc.) and then show or hide that folder. This obviously means you would have to name your folders appropriately.

There may well be a more elegant solution but that is the first thing that came to mind.