input: Write a function to generate a Python program that compares two binary trees to check if they are similar. The function should take two root nodes of the trees as input and return True if the trees are similar, otherwise return False. If both trees are empty, return True.
  
  assert are_similar(None, None)==True
  assert are_similar(TreeNode(1), None)==False
  assert are_similar(None, TreeNode(1))==False
  assert are_similar(TreeNode(1), TreeNode(1))==True
  
  class TreeNode:
      def __init__(self, x):
          self.val = x
          self.left = None
          self.right = None
  
  def are_similar(root1, root2):
      if root1 is None and root2 is None:
          return True
      if (root1 and root2) is None or (root1 or root2) is None:
          return False
      if root1.val != root2.val:
          return False
      else:
          return are_similar(root1.left, root2.left) and are_similar(root1.right, root2.right)
output: def are_similar(root1, root2):
      if root1 is None and root2 is None:
          return True
      if root1 is None or root2 is None:
          return False
      if root1.val != root2.val:
          return False
      return are_similar(root1.left, root2.left) and are_similar(root1.right, root2.right)