If an arc_element is modified and it's characters/locations are not already in the story node, add them.
    We don't assume that removing the arc element would change the characters or locations as of yet.
    This takes up a little more space in the database, but the additional flexibility for users is
    worth it.

def arc_node_edit_add_missing_characters_and_locations_to_related_story_node(
        sender,
        instance,
        action,
        reverse,
        pk_set,
        *args,
        **kwargs
):
    '''
    If an arc_element is modified and it's characters/locations are not already in the story node, add them.
    We don't assume that removing the arc element would change the characters or locations as of yet.
    This takes up a little more space in the database, but the additional flexibility for users is
    worth it.

    '''
    if action == 'post_add':
        logger.debug("Updating nodes after character or location change.")
        if reverse:
            logger.debug("Searching backwards from character or location to arc node")
            # We are going to need to be querying the arc element node.
            for arcnode in instance.arcelementnode_set.all().select_related('story_element_node'):
                logger.debug("Scanning arc node...")
                if arcnode.story_element_node:
                    logger.debug("Found story node to update...")
                    story_node = arcnode.story_element_node
                    if isinstance(instance, CharacterInstance):
                        logger.debug("Updating characters...")
                        story_node.assoc_characters.add(instance)
                    if isinstance(instance, LocationInstance):
                        logger.debug("updating locations...")
                        story_node.assoc_locations.add(instance)
        else:
            # We already have the arc_element_node
            logger.debug('Scanning arcnode instance...')
            if instance.story_element_node:
                logger.debug("found story node to update...")
                story_node = instance.story_element_node
                if sender == ArcElementNode.assoc_characters.through:
                    logger.debug('Adding character')
                    story_node.assoc_characters.add(*pk_set)
                if sender == ArcElementNode.assoc_locations.through:
                    logger.debug('Adding locations')
                    story_node.assoc_locations.add(*pk_set)