def flatten_nested_dict(dic):
    """Flatten a nested dictionary.

    dic = {'a': {'b': 1}}
    will be flattened as
    new_dic = {'a.b': 1}
    """
    new_dic = dict()
    for key, val in dic.items():
        if isinstance(val, dict):
            tmp_dict = flatten_nested_dict(val)
            for new_key, new_val in tmp_dict.items():
                new_dic[key+'.'+new_key] = new_val
        else:
            new_dic[key] = val
    return new_dic