Here's a straightforward algorithm to determine the successor of a node in a binary search tree (BST): def successorBST(root, targetNode): # If the targetNode has a right child, the successor is the smallest value in the right subtree if targetNode.right is not None: return findMinValue(targetNode.right) # If there is no right child, the successor is one of the ancestors. We traverse from the root. successor = None while root: if targetNode.value < root.value: successor = root root = root.left elif targetNode.value > root.value: root = root.right else: break return successor In this algorithm, the findMinValue function simply traverses down to the leftmost leaf, which will contain the smallest value in the tree or subtree.