def flatten_dict(d):
    result = {}
    for key, value in d.items():
        if isinstance(value, dict) and value:
            for sub_key, sub_value in flatten_dict(value).items():
                result[f"{key}.{sub_key}"] = sub_value
        else:
            result[key] = value
    return result
