<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def validate_location_instance_valid_for_arc(sender, instance, action, reverse, pk_set, *args, **kwargs):
    '''
    Evaluates attempts to add location instances to arc, ensuring they are from same outline.
    '''
    if action == 'pre_add':
        if reverse:
            # Fetch arc definition through link.
            for apk in pk_set:
                arc_node = ArcElementNode.objects.get(pk=apk)
                if arc_node.parent_outline != instance.outline:
                    raise IntegrityError(_('Location instance must be from same outline as arc element.'))
        else:
            for lpk in pk_set:
                loc_instance = LocationInstance.objects.get(pk=lpk)
                if loc_instance.outline != instance.parent_outline:
                    raise IntegrityError(_('Location Instance must be from the same outline as arc element.'))