'Update parent of an item if it has moved.
Arguments:
original_parent_location (BlockUsageLocator)  : Original parent block locator.
published_version (dict)   : Published version of the block.
delete_draft_only (function)    : A callback function to delete draft children if it was moved.
user_id (int)   : User id'

def update_parent_if_moved(self, original_parent_location, published_version, delete_draft_only, user_id):

    for child_location in published_version.get('definition', {}).get('children', []):
        item_location = original_parent_location.course_key.make_usage_key_from_deprecated_string(child_location)
        try:
            source_item = self.get_item(item_location)
        except ItemNotFoundError:
            log.error('Unable    to    find    the    item    %s', unicode(item_location))
            return
        if (source_item.parent and (source_item.parent.block_id != original_parent_location.block_id)):
            if self.update_item_parent(item_location, original_parent_location, source_item.parent, user_id):
                delete_draft_only(Location.from_deprecated_string(child_location))
