def replace_periods(dict_val, replace_with='_'):
    """
    Recursively replace "." fonud in keys in the given dict with the value
        of replace_with
    """
    facts = dict()
    for k, v in dict_val.items():
        if '.' in k:
            if replace_with:
                k = k.replace('.', '_')
        if isinstance(v, dict):
            facts[k] = replace_periods(v)
        else:
            facts[k] = v
    return facts