input: from typing import Optional
  
  class Node: 
        
      def __init__(self, data): 
          self.data = data 
          self.left = None
          self.right = None
    
  def isSubTree(T: Optional[Node], S: Optional[Node]) -> bool:
      """ Check if the binary tree S is a subtree of the binary tree T.
      >>> T1 = Node(1)
      >>> T1.left = Node(2)
      >>> T1.right = Node(3)
      >>> T1.left.left = Node(4)
      >>> T1.left.right = Node(5)
      >>> S1 = Node(2)
      >>> S1.left = Node(4)
      >>> S1.right = Node(5)
      >>> isSubTree(T1, S1)
      True
      >>> T2 = Node(1)
      >>> T2.left = Node(2)
      >>> T2.right = Node(3)
      >>> T2.left.left = Node(4)
      >>> T2.left.right = Node(5)
      >>> S2 = Node(2)
      >>> S2.left = Node(4)
      >>> S2.right = Node(6)
      >>> isSubTree(T2, S2)
      False
      """
      
      def areIdentical(T: Optional[Node], S: Optional[Node]) -> bool: 
        
          if T is None and S is None: 
              return True
  
          if T is None or S is None: 
              return False
  
          return (T.data == S.data and 
                  areIdentical(T.left, S.left) and
                  areIdentical(T.right, S.right))
      
      if S is None: 
          return True
    
      if T is None: 
          return False
    
      if areIdentical(T, S): 
          return True
    
      return isSubTree(T.left, S) or isSubTree(T.right, S)
output:     def areIdentical(T: Optional[Node], S: Optional[Node]) -> bool: 
        
          if T is None and S is None: 
              return True
  
          if T is None or S is None: 
              return False
  
          return (T.data == S.data and 
                  areIdentical(T.left, S.left) and
                  areIdentical(T.right, S.right))
      
      if S is None: 
          return True
    
      if T is None: 
          return False
    
      if areIdentical(T, S): 
          return True
    
      return isSubTree(T.left, S) or isSubTree(T.right, S)