def simplify_nested_dict(dictionary, name, separator='_'):
    """
    Takes a nested dictionary and transforms it into a flat one.

    :param dictionary: (dict) dictionary to transform
    :return: (dict) result dictionary
    """
    res = dict()
    for key in dictionary:
        if isinstance(dictionary[key], dict):
            res.update(simplify_nested_dict(
                dictionary[key],
                "{}{}{}".format(name, separator, key),
                separator))
        else:
            res['{}{}{}'.format(name, separator, key)] = dictionary[key]
    return res