input: from typing import Optional
  
  class TreeNode:
      def __init__(self, value):
          self.value = value
          self.left = None
          self.right = None
  
  def dropLeafNodes(head: Optional[TreeNode]) -> Optional[TreeNode]:
      """ Drop all leaf nodes from the given Huffman tree.
      >>> head = TreeNode(1)
      >>> head.left = TreeNode(2)
      >>> head.right = TreeNode(3)
      >>> head.left.left = TreeNode(4)
      >>> head.left.right = TreeNode(5)
      >>> head.right.left = TreeNode(6)
      >>> head.right.right = TreeNode(7)
      >>> modified_head = dropLeafNodes(head)
      >>> modified_head.value
      1
      >>> modified_head.left.value
      2
      >>> modified_head.right.value
      3
      >>> modified_head.left.left
      >>> modified_head.left.right
      >>> modified_head.right.left
      >>> modified_head.right.right
      """
      if head and not head.left and not head.right: 
          return None
    
      if not head: 
          return None
    
      head.left = dropLeafNodes(head.left) 
      head.right = dropLeafNodes(head.right) 
    
      return head
output:     if head and not head.left and not head.right: 
          return None
    
      if not head: 
          return None
    
      head.left = dropLeafNodes(head.left) 
      head.right = dropLeafNodes(head.right) 
    
      return head