input: Write a function to drop all the leaf nodes from a Huffman tree. If the node doesn't have any children, it should be removed. If the head node is None, return None. The function should recursively check all nodes in the tree.
  
  def dropLeafNodes(head): 
      
      # If node is not None and doesn't have any children 
      if head and not head.left and not head.right: 
          return None
    
      # Don't change anything if head is None 
      if not head: 
          return None
    
      # Recursively call dropLeafNodes on left and right subtrees
      head.left = dropLeafNodes(head.left) 
      head.right = dropLeafNodes(head.right) 
    
      # Return head of the modified tree
      return head
  
  assert dropLeafNodes(None) == None
  
  leaf = TreeNode(7)
  leaf.left = TreeNode(6)
  leaf.right = TreeNode(8)
  node1 = TreeNode(3)
  node1.left = TreeNode(4)
  node1.right = leaf
  node2 = TreeNode(2)
  node2.left = TreeNode(5)
  node2.right = node1
  head = TreeNode(1)
  head.left = node2
  head.right = None
  assert dropLeafNodes(head) == head
  
  leaf = TreeNode(4)
  node1 = TreeNode(2)
  node1.left = leaf
  node1.right = None
  head = TreeNode(1)
  head.left = node1
  head.right = None
  assert dropLeafNodes(head) == head
  
  head = TreeNode(1)
  assert dropLeafNodes(head) == None
output: def dropLeafNodes(head): 
      
      # If node is not None and doesn't have any children 
      if head and not head.left and not head.right: 
          return None
    
      # Don't change anything if head is None 
      if not head: 
          return None
    
      # Recursively call dropLeafNodes on left and right subtrees
      head.left = dropLeafNodes(head.left) 
      head.right = dropLeafNodes(head.right) 
    
      # Return head of the modified tree
      return head