Multi-page sidebar categorized into subdirectories

Problem

When you have more pages, you will want to display the list of pages categorized in subdirectories in the sidebar as well, categorized in the same way.

Solution.

MVP: What is the minimum solution that will solve 80% of the problem?
I couldn’t figure out how to make it with a custom component, so I forked the streamlit body and made a modified implementation.
If there is demand, I will try to create a pull-request.
I have not added test code yet.
It would be helpful if you could tell me what I should pay attention to before creating a pull-request.

Additional Context.