input: Write a function to determine the sum of all elements in a given binary tree. If the tree is empty, return 0. Assume that each node in the tree has an integer value stored in the attribute 'val'.
  
  def sum_tree(root):
      if root is None:
          return 0
  
      return root.val + sum_tree(root.left) + sum_tree(root.right)
  
  assert sum_tree(None) == 0
  assert sum_tree(TreeNode(1, None, None)) == 1
  assert sum_tree(TreeNode(1, TreeNode(2, TreeNode(3, None, None), TreeNode(4, None, None)), TreeNode(5, None, None))) == 15
output: def sum_tree(root):
      if root is None:
          return 0
  
      return root.val + sum_tree(root.left) + sum_tree(root.right)