Removed many unnecessary uses of dict.keys

This has a few advantages: some of these locations will perform
slightly faster, it's minutely less code, and dict.keys has a different
behavior on Python 3. Also removes usage of dict.iterkeys, which is
identical to just iterating over the dict, except it doesn't exist on
Python 3 at all.

Change-Id: Ia91e97232dc8d78cf63fa807de288fc25cf5425d
Merge "Removed many unnecessary uses of dict.keys"