code: def clean_dict(d):
      
  
      if not isinstance(d, (dict, list)):
          return d
      if isinstance(d, list):
          return [v for v in (clean_dict(v) for v in d) if v]
      return OrderedDict(
          [(k, v) for k, v in ((k, clean_dict(v)) for k, v in list(d.items())) if v]
      )
docs: Remove all empty fields in a nested dict