'Update parent of an item if it has moved.
Arguments:
item_location (BlockUsageLocator)    : Locator of item.
original_parent_location (BlockUsageLocator)  : Original parent block locator.
course_structure (dict)  : course structure of the course.
user_id (int)   : User id'

def update_parent_if_moved(self, item_location, original_parent_location, course_structure, user_id):

    parent_block_keys = self._get_parents_from_structure(BlockKey.from_usage_key(item_location), course_structure)
    for block_key in parent_block_keys:
        if (block_key.id != original_parent_location.block_id):
            old_parent_location = original_parent_location.course_key.make_usage_key(block_key.type, block_key.id)
            self.update_item_parent(item_location, original_parent_location, old_parent_location, user_id)
