def _get_new_parent(moved, target, position='first-child'):
    """
    Find out which parent the node will reside under.
    """
    if position in ('first-child', 'last-child'):
        return target
    elif position in ('left', 'right'):
        parent_attr_id = '{}_id'.format(moved._mptt_meta.parent_attr)
        if getattr(target, parent_attr_id) == getattr(moved, parent_attr_id):
            return getattr(moved, moved._mptt_meta.parent_attr)
        return getattr(target, target._mptt_meta.parent_attr)
    else:
        raise ValueError('invalid mptt position argument')
