class Solution:
    def GetNext(self, pNode):
        # write code here
        # 此节点有右子树
        if pNode.right:
            temp = pNode.right
            while temp:
                result = temp
                temp = temp.left
            return result
        # 此节点没有右子树
        while pNode:
            if pNode.next:
                if pNode.next.left == pNode:
                    return pNode.next
                pNode = pNode.next
            else:
                return None