class Solution:

# @param A : root node of tree

# @param B : integer

# @return the root node in the tree

```
def getSuccessor(self, A, B):
stack = []
stack.append(A)
temp = A.left
node_found = False
while stack:
while temp != None:
stack.append(temp)
temp = temp.left
cur_node = stack.pop()
if node_found == True:
return cur_node
if cur_node.val == B:
node_found = True
temp = cur_node.right
return None
```