'Return the location (Locators w/ block_ids) for the parent of this location in this
course. Could use get_items(location, {\'children\': block_id}) but this is slightly faster.
NOTE: the locator must contain the block_id, and this code does not actually ensure block_id exists
:param locator: BlockUsageLocator restricting search scope'

def get_parent_location(self, locator, **kwargs):

    if ((not isinstance(locator, BlockUsageLocator)) or locator.deprecated):
        raise ItemNotFoundError(locator)
    course = self._lookup_course(locator.course_key)
    all_parent_ids = self._get_parents_from_structure(BlockKey.from_usage_key(locator), course.structure)
    parent_ids = [valid_parent for valid_parent in all_parent_ids if self.has_path_to_root(valid_parent, course)]
    if (len(parent_ids) == 0):
        return None
    parent_ids.sort(key=(lambda parent: (parent.type, parent.id)))
    return BlockUsageLocator.make_relative(locator, block_type=parent_ids[0].type, block_id=parent_ids[0].id)
