def add_branch(tree, vector, value):
    """Recursively update dictionary given a vector containing the path of
    the branch. Useful for directly adding a value at a specified key path.

    Source: https://stackoverflow.com/a/59634887/6654930
    """
    key = vector[0]
    if len(vector) == 1:
        tree[key] = value
    else:
        tree[key] = add_branch(tree[key] if key in tree else {}, vector[1:], value)
    return tree