TreeNode has constructors that accepts a parent node to which the new node is added to. This leads to the following code:
new TrreNode("node1", parent);
a little confusing because the newly created node isn't assigned and looks unused.
By using one of the alternative consturctors we get this:
TreeNode child = new TrreNode("node1");
Now the code is clear as to what is happening.