def flatten_recursive(item):
  """Flattens (potentially nested) a tuple/dictionary/list to a list."""
  output = []
  if isinstance(item, (list, tuple)):
    output.extend(item)
  elif isinstance(item, abc.Mapping):
    output.extend(item.values())
  else:
    return [item]

  return itertools.chain.from_iterable(map(flatten_recursive, output))
Flattens (potentially nested) a tuple/dictionary/list to a list.
language/canine/modeling_test.py