def iteritems_nested(d):
    """
    Collect dictionary keys until the deepest level.
    """

    def fetch(suffixes, v0):
        if isinstance(v0, dict):
            for k, v in v0.items():
                yield from fetch(suffixes + [k], v)
        else:
            yield (suffixes, v0)

    return fetch([], d)