Prevent dictionary size from changing while iterating over its items

In Python 3, dict.items() returns 'a dict_item'. Iterating over it while
deleting some of the dictionary elements is forbidden. We have to iterate over
a list to avoid getting this error:

    RuntimeError: dictionary changed size during iteration

Change-Id: I43401e6eb9a31148fda4677644bf99e1b739d0dd
Merge "Prevent dictionary size from changing while iterating over its items"