def flatten_dict(value):
    if not isinstance(value, dict):
        return value
    out = {}
    for key, sub in value.items():
        if isinstance(sub, dict):
            if sub:
                for k, v in flatten_dict(sub).items():
                    out[f"{key}.{k}"] = v
            else:
                out[key] = {}
        else:
            out[key] = sub
    return out
