The idea is to use any of the tree traversals to traverse the tree and while traversing check if the current node matches with the given node, return true if any node matches with the given node and stop traversing further and if the tree is completely traversed and none of the node matches with the given node then return False.
Below is the implementation of the above approach:
Output
True
Time Complexity: O(n), where n is the number of nodes in the tree. Auxiliary Space: O(h), where h is the height of the tree.