We can pick data-structures which are convenient to our application.
Javascript objects that we define for our needs are easier than dealing with all the obscure quirks of thirty years of history with the browser APIs for DOM objects.
This is much better than putting state on DOM objects which are in an arbitrary tree structure for how they are displayed in the browser.
For instance for the tree control example it makes sense to have a nested dictionary that stores the tree data but for the expansion nodes to have that stored in a flat dictionary mapping the IDs of nodes which need to be expanded.