code: def prune_empty_node(node, seen):
      
      if node.methods:
          return False
      if id(node) in seen:
          return True
      seen = seen | {id(node)}
      for branch in list(node.branches):
          if prune_empty_node(branch, seen):
              node.branches.remove(branch)
          else:
              return False
      return True
docs: Recursively remove empty branches and return whether this makes the node
      itself empty.
  
      The ``seen`` parameter is used to avoid infinite recursion due to cycles
      (you never know).