public void clearChildren ( ) { // Check that their are children to clear. if ( children != null ) { // Loop over all the children setting their parent to null. for ( Tree < E > child : children ) { child . setParent ( null ) ; } // Clear out the children collection. children . clear ( ) ; // Mark this as a leaf node. nodeOrLeaf = Type . Leaf ; } }
Clears all the children of this point in the tree . If this point is a leaf it will have no children so this operation does nothing . If this point is a node it will be reduced to a leaf by this operation . This implementation supports turning nodes into leaves .