input: 
  def isSubTree(T, S):
      """ Check if a binary tree S is a subtree of binary tree T.
      >>> isSubTree(None, None)
      True
      >>> isSubTree(Node(5), None)
      True
      >>> isSubTree(Node(5), Node(5))
      True
      >>> isSubTree(Node(5), Node(6))
      False
      >>> T = Node(5); T.left = Node(3); T.right = Node(8)
      >>> S = Node(5); S.left = Node(3); S.right = Node(8)
      >>> isSubTree(T, S)
      True
      >>> T = Node(5); T.left = Node(3); T.right = Node(8)
      >>> S = Node(5); S.left = Node(3)
      >>> isSubTree(T, S)
      True
      >>> T = Node(5); T.left = Node(3); T.right = Node(8)
      >>> S = Node(5); S.left = Node(3); S.right = Node(9)
      >>> isSubTree(T, S)
      False
      """
      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)
    
  def areIdentical(T, S):
      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))
  
output:     class Node:
          def __init__(self, data):
              self.data = data
              self.left = None
              self.right = None