code: def flatten_dict(source, ancestors=None):
    
    if not ancestors:
      ancestors = ()
    for key in source:
      if isinstance(source[key], dict):
        yield from flatten_dict(source[key], ancestors + (key, ))
      else:
        yield (ancestors + (key, ), source[key])
docs: Flattens a dictionary into (key, value) tuples. Where key is a tuple of ancestor keys.
  
    :source: the root dictionary
    :ancestors: the tuple of ancestors for every key in :source: