Here is my sample code:

```
def clean(record):

    record.pop('configurable_fields')
    record.pop('applied_discounts')
    record.pop('product_options')

    for key, value in record.items():
        if value is None:
            record.pop(key)

    return record

```

I get this error:

```
Traceback (most recent call last):
  File "C:\Users\Filipe\Dropbox\code\bigAnalysis\finalized scripts\importer.py", line 76, in <module>
    process_file('allOrderProductsData')
  File "C:\Users\Filipe\Dropbox\code\bigAnalysis\finalized scripts\importer.py", line 73, in process_file
    process_line(line)
  File "C:\Users\Filipe\Dropbox\code\bigAnalysis\finalized scripts\importer.py", line 58, in process_line
    product_id = dump_record('package', clean(package))  # id of recently created record
  File "C:\Users\Filipe\Dropbox\code\bigAnalysis\finalized scripts\importer.py", line 40, in clean
    for key, value in record.items():
RuntimeError: dictionary changed size during iteration

```

I tried some solutions I found in others thread like using copy.deecopy, but none of them worked so far.