from typing import Any


def deepset(data: dict, keys: list[str], value: Any):
    """
    deepset nested keys to a value in a dictionary, filling in nested dictionaries
    when needed.
    """

    if keys:
        k = keys.pop(0)
        subdata = data[k] if k in data else {}
        data[k] = deepset(subdata, keys, value)
        return data

    else:
        return value