Given the information of the leaf node, how to get the information of all the nodes of the corresponding branch?

recently encountered a requirement that the data structure is a tree structure.
is when I click on a child node and need to get an attribute value for all nodes of the corresponding branch. The data structure is shown in the following figure.

   

for example, I click E to get the level and information of E. How do I get information about the corresponding branches (B and A) at the same time? Ask the great god for advice.


just save a reference to the parent node, if you don't care about circular references.
the second way is to maintain a weakMap, where key is the key,value of each node. Then you only need to save the key of the parent node and look for it with key when you want to use it. It is equivalent to manually implementing a pointer.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7b1cb7-825e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7b1cb7-825e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?