There are two cases:
1. if the node has right child, then find the minimum element of the subtree rooted at the right of this node. By BST property, this is the successor of our node.
2. if node has no right subtree, then this node must be the maximum of a certain tree. So for the root of this tree, it should be left child of another node N or it is the root of the whole BST. if it is N, then N is our successor, otherwise there is no successor(since we are the right most node of the whole BST).
O(h) (h means height of the tree)