def update_on_value(tdict, tkey, value, first=True):
    """
    Update target dictionary and set tdict[tkey] to value, if value exists and
    is not None. If the value in question is a sequence, first controls,
    whether only the first element should be used as value.
    """
    if value is not None:
        if first and isinstance(value, (list, tuple)):
            if len(value) > 0:
                tdict[tkey] = value[0]
        else:
            tdict[tkey] = value
