def flatten(dictionary, parent_key=False, separator='<STR_LIT:.>'):
items = []<EOL>for key, value in dictionary.items():<EOL><INDENT>new_key = str(parent_key) + separator + key if parent_key else key<EOL>if isinstance(value, collections.MutableMapping):<EOL><INDENT>items.extend(flatten(value, new_key, separator).items())<EOL><DEDENT>elif isinstance(value, list):<EOL><INDENT>for k, v in enumerate(value):<EOL><INDENT>items.extend(flatten({str(k): v}, new_key).items())<EOL><DEDENT><DEDENT>else:<EOL><INDENT>items.append((new_key, value))<EOL><DEDENT><DEDENT>return dict(items)<EOL>
Turn a nested dictionary into a flattened dictionary

:param dictionary: The dictionary to flatten
:param parent_key: The string to prepend to dictionary's keys
:param separator: The string used to separate flattened keys
:return: A flattened dictionary