Inorder Successor in Binary Search Tree
Your code is correct if the key of one node is never equal to the key of a different node. 

Otherwise, you code fails to return the correct inorder-successor of the node at the bottom of the following graph.