input: def is_subtree(T: Node, S: Node) -> bool:
      """
      Given two binary trees, check if the first tree is a subtree of the second tree.
      
      >>> node1 = Node(1)
      >>> node2 = Node(2)
      >>> node3 = Node(3)
      >>> node1.left = node2
      >>> node1.right = node3
      >>> node4 = Node(4)
      >>> is_subtree(node1, node2)
      True
      >>> is_subtree(node1, node4)
      False
      """
output:     if not S:
          return True
      if not T:
          return False
      
      def is_identical(root1, root2):
          if not root1 and not root2:
              return True
          if not root1 or not root2:
              return False
          return (root1.val == root2.val and 
                  is_identical(root1.left, root2.left) and 
                  is_identical(root1.right, root2.right))
      
      def traverse(root, subroot):
          if not root:
              return False
          if is_identical(root, subroot):
              return True
          return traverse(root.left, subroot) or traverse(root.right, subroot)
      
      return traverse(T, S)