Get pointers to all unique top-level and nested keys
import collections
def get_keys(d, keys=None, pointer=None, sep='.', prefix=''):
if keys is None:
keys = set()
if pointer is None:
pointer = []
for key, value in d.items():
keyptr = pointer + [str(key)]
keys.add(prefix + sep.join(keyptr))
if isinstance(value, collections.Mapping):
keys |= get_keys(value, None, keyptr, sep, prefix)
return keys
keys = (get_keys(i) for i in items)