Function to store the path from root node to given node of the tree in path vector and then returns true if the path exists otherwise false
def FindPath ( root , path , key ) : NEW_LINE INDENT if root == None : NEW_LINE INDENT return False NEW_LINE DEDENT path . append ( root . data ) NEW_LINE if root . data == key : NEW_LINE INDENT return True NEW_LINE DEDENT if ( FindPath ( root . left , path , key ) or FindPath ( root . right , path , key ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT path . pop ( ) NEW_LINE return False NEW_LINE DEDENT