+ if ( isRoot() ) {
+ return null;
+ }
+ if ( getParent().isCollapse() ) {
+ throw new UnsupportedOperationException( "attempt to get next external node of node with a collapsed parent" );
+ }
+ // This checks if last node.
+ PhylogenyNode n = this;
+ boolean last = true;
+ while ( !n.isRoot() ) {
+ if ( !n.isLastChildNode() ) {
+ last = false;
+ break;
+ }
+ n = n.getParent();
+ }
+ if ( last ) {