def update_dict_recursively(dictionary, key_path, value):
    """
    update or insert values to a dictionary recursively.

    ```
    >>> update_dict_recursively({}, ['a', 'b', 1, 2], 'this_value')
    {'a': {'b': {1: {2: 'this_value'}}}}
    ```

    :param dict dictionary: the dictionary to be inserted into
    :param list key_path: the path for the insertion value
    :param value: value to be inserted
    :returns: a dictionary with the inserted value
    """
    sub_dictionary = dictionary
    for key in key_path[:-1]:
        if key not in sub_dictionary:
            sub_dictionary[key] = {}
        sub_dictionary = sub_dictionary[key]

    sub_dictionary[key_path[-1]] = value

    return dictionary