public boolean goForward ( ) { if ( currentNode . hasChildren ( ) ) { currentNode = currentNode . getChildren ( ) . get ( 0 ) ; return true ; } else if ( currentNode . getParent ( ) == null ) { return false ; } while ( true ) { N parent = currentNode . getParent ( ) ; if ( ( parent == null ) || ( currentNode == tree ) ) { return false ; } int index = parent . getChildren ( ) . indexOf ( currentNode ) ; if ( parent . getChildren ( ) . size ( ) > index + 1 ) { currentNode = parent . getChildren ( ) . get ( index + 1 ) ; return true ; } else { currentNode = parent ; } } }
This method walks forward one node .