def flatten_a_record (rec, prefix='', sep='.'):
  """
  Flatten the given record (dictionary) into a list of key/value tuples and
  return the tuple list.
  Arguments:
    rec: the dictionary to be flattened.
    prefix: the prefix key "path" at this level of flattening. If provided, must
            already include the separator as a suffix.
    sep: the string to use to separate the levels in the prefix key "path".
  """
  entries = []
  for key, val in rec.items():
    if (isinstance(val, dict)):
      new_prefix = f"{prefix}{key}{sep}"
      entries.extend(flatten_a_record(val, prefix=new_prefix, sep=sep))
    else:
      top_key = f"{prefix}{key}"
      entries.append((top_key, val))
  return entries