code: def remove_folder(self, tree, prefix):
          
          while True:
              child = tree
              tree = tree.parent
  
              if not child.folders and not child.files:
                  del self.cache[tuple(prefix)]
                  if tree:
                      del tree.folders[prefix.pop()]
  
              if not tree or tree.folders or tree.files:
                  break
docs: Used to remove any empty folders
  
          If this folder is empty then it is removed. If the parent is empty as a
          result, then the parent is also removed, and so on.