code: def remove_empty_dirs(path=None):
      
  
      if not path:
          path = settings.MEDIA_ROOT
  
      if not os.path.isdir(path):
          return False
  
      listdir = [os.path.join(path, filename) for filename in os.listdir(path)]
  
      if all(list(map(remove_empty_dirs, listdir))):
          os.rmdir(path)
          return True
      else:
          return False
docs: Recursively delete empty directories; return True if everything was deleted.