Here is an exercise for you.
Read the names of all these functions here, and click on view source for each.
https://google.github.io/closure-library/api/goog.ui.tree.TreeNode.html
After comprehending all the code then try to express all of it in one function that doesn't require any pre-existing knowledge about the data to be parsed.
The more you know…