Keep open tree node when reloading a page

Hello,
I am enchanted by the many possibilities that XWiki offers. Unfortunately, I am not an experienced programmer and often reach my limits.

I am currently struggling with the following question: I have a structure of many pages in a certain content hierarchy that cannot be realised with alphabetical titles. A display with the standard macros is therefore not useful.
However, I can easily implement the required structure with the tree macro. It works and there are enough options for further customisation.

What I am still missing, however, is the following possibility: How do I get the state of the tree if I click on one of the entries and the entire page reloads as a result? This happens, for example, when I integrate my tree structure in a panel in the navigation area and then use it. The tree can be expanded, but as soon as I click on an entry, the corresponding page is opened in the page area. But the tree is collapsed again when the page is reloaded.

The navigation panel actually already has this function (call up link from tree, but remember node and open again), but I don’t know how I can transfer it to the tree macro.

Or is there a completely different implementation idea?