<garvit244>285_1.py
def inorderSuccessor( root, p):
    if not root or not p:
        return None
    
    if p.right:
        p = p.right
        while p.left:
            p = p.left
        return p
    
    successor = None
    while root and root != p:
        if root.val > p.val:
            successor = root
            root = root.left
        else:
            root = root.right
    return successor
def sample_funcname ( var_0 , var_1 ) :
    if not var_0 or not var_1 :
        return None
    if var_1.right :
        var_1 = var_1.right
        while var_1.left :
            var_1 = var_1.left
        return var_1
    var_5 = None
    while var_0 and var_0 != var_1 :
        if var_0.val > var_1.val :
            var_5 = var_0
            var_0 = var_0.left
        else :
            var_0 = var_0.right
    return var_5
