public Iterator < Compound > toRootOrder ( final Compound c ) { return new Iterator < Compound > ( ) { Compound curr ; TreeNode n = node ( c ) ; Compound parent = c ; public boolean hasNext ( ) { return ! n . isRoot ( ) ; } public Compound next ( ) { if ( hasNext ( ) ) { curr = parent ; parent = n . parent ; n = node ( n . parent ) ; return curr ; } else { throw new NoSuchElementException ( ) ; } } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; }
Returns all compounds from the Compound argument to the root of the tree following the path .