[Python 3] Avoids iterating directly over a dict that's being modified.