'Updates item\'s parent and removes it\'s reference from old parent.
Arguments:
item_location (BlockUsageLocator)    : Locator of item.
new_parent_location (BlockUsageLocator)  : New parent block locator.
old_parent_location (BlockUsageLocator)  : Old parent block locator.
user_id (int)   : User id.
insert_at (int) : Insert item at the particular index in new parent.
Returns:
BlockUsageLocator or None: Source item location if updated, otherwise None.'

def update_item_parent(self, item_location, new_parent_location, old_parent_location, user_id, insert_at=None):

    try:
        source_item = self.get_item(item_location)
        old_parent_item = self.get_item(old_parent_location)
        new_parent_item = self.get_item(new_parent_location)
    except ItemNotFoundError as exception:
        log.error('Unable    to    find    the    item    :    %s', exception.message)
        return
    if (source_item.location in old_parent_item.children):
        old_parent_item.children.remove(source_item.location)
        self.update_item(old_parent_item, user_id)
        log.info('%s    removed    from    %s    children', unicode(source_item.location), unicode(old_parent_item.location))
    if (source_item.location not in new_parent_item.children):
        if (insert_at is not None):
            new_parent_item.children.insert(insert_at, source_item.location)
        else:
            new_parent_item.children.append(source_item.location)
        self.update_item(new_parent_item, user_id)
        log.info('%s    added    to    %s    children', unicode(source_item.location), unicode(new_parent_item.location))
    source_item.parent = new_parent_location
    self.update_item(source_item, user_id)
    log.info('%s    parent    updated    to    %s', unicode(source_item.location), unicode(new_parent_item.location))
    return source_item.location
