A tree Node’s successor is the smallest child Node that is larger than the current Node.


Finding the Successor

To find a Node’s successor, read the leftmost node that is a child of the current Node’s right child.

static Node getSuccessor(Node node) {
	if(node == null || node.right == null) return null;
 
	return leftmostChild(node.right);
}
 
static Node leftmostChild(Node node) {
	if(node.left == null) return node;
 
	return leftmostChild(node.left);
}