title: Elegant way to remove fields from nested dictionaries
body: <p>I had to remove some fields from a dictionary, the keys for those fields are on a list. So I wrote this function:</p>
  
  <pre><code>def delete_keys_from_dict(dict_del, lst_keys):
      """
      Delete the keys present in lst_keys from the dictionary.
      Loops recursively over nested dictionaries.
      """
      dict_foo = dict_del.copy()  #Used as iterator to avoid the 'DictionaryHasChanged' error
      for field in dict_foo.keys():
          if field in lst_keys:
              del dict_del[field]
          if type(dict_foo[field]) == dict:
              delete_keys_from_dict(dict_del[field], lst_keys)
      return dict_del
  </code></pre>
  
  <p>This code works, but it's not very elegant and I'm sure that there is a better solution.</p>