input: Write a function to compare two binary trees and determine if they are similar. If both trees are empty, they are considered similar. If they have the same structure and values at corresponding nodes, they are considered similar. If any node in one tree differs in value or structure from the corresponding node in the other tree, they are not similar.
  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 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)
  
  # Test cases
  assert are_similar(None, None) == True
  assert are_similar(TreeNode(1), TreeNode(1)) == True
  assert are_similar(TreeNode(1), TreeNode(2)) == False
  assert are_similar(TreeNode(1, TreeNode(2), TreeNode(3)), TreeNode(1, TreeNode(2), TreeNode(3))) == True
  assert are_similar(TreeNode(1, TreeNode(2), TreeNode(3)), TreeNode(1, TreeNode(3), TreeNode(2))) == False
  assert are_similar(TreeNode(1, TreeNode(2), None), TreeNode(1, TreeNode(2), TreeNode(3))) == False
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)