public void addChild ( Tree < E > child ) { initChildren ( ) ; // Add the new child to the collection of children. children . add ( child ) ; // Set the type of this point in the tree to a node as it now has children. nodeOrLeaf = Type . Node ; // Set the new childs parent to this. child . setParent ( this ) ; }
Adds a child tree to the children of this point in the tree . If this is already a node then it remains as a node . If this is a leaf then adding a child to it must promote it to become a node . This implementation supports turning leaves into nodes .