If q has right child , then right child is nextRight of p and we also need to set nextRight of right child
if ( q . right != null ) { q . left . nextRight = q . right ; } else { q . left . nextRight = getNextRight ( q ) ; } } if ( q . right != null ) { q . right . nextRight = getNextRight ( q ) ; }