def set_value_in_place(target_object, key, new_value):
    """
    updates the value at key in the given object in place
    :param target_object: the object to change the value of
    :param key:  the key to change - can be a path like color/r for the key r in the underlying object color
    :param new_value: the value to set it to

    """

    # split the key, so we can have key be multilevel.
    k = key.split("/", 1)
    # print("k ", k, len(k))
    if len(k) > 1:
        if k[0] not in target_object:
            target_object[k[0]] = set_value_in_place({}, k[1], new_value)

        else:
            target_object[k[0]] = set_value_in_place(target_object[k[0]], k[1], new_value)

    else:
        target_object[key] = new_value
    return target_object