Check if x is present at root or in left subtree or right subtree .
if ( root . data == x ) : NEW_LINE INDENT return dist + 1 NEW_LINE DEDENT else : NEW_LINE INDENT dist = findDistance ( root . left , x ) NEW_LINE if dist >= 0 : NEW_LINE INDENT return dist + 1 NEW_LINE DEDENT else : NEW_LINE INDENT dist = findDistance ( root . right , x ) NEW_LINE if dist >= 0 : NEW_LINE INDENT return dist + 1 NEW_LINE DEDENT DEDENT DEDENT return dist NEW_LINE