'Helper for get_parent_location that finds the location that is the parent of this location in this course,
but does NOT return a version agnostic location.'

def _get_raw_parent_location(self, location, revision=ModuleStoreEnum.RevisionOption.published_only):

    assert (location.revision is None)
    assert ((revision == ModuleStoreEnum.RevisionOption.published_only) or (revision == ModuleStoreEnum.RevisionOption.draft_preferred))
    parent_cache = self._get_parent_cache(self.get_branch_setting())
    if parent_cache.has(unicode(location)):
        return parent_cache.get(unicode(location))
    query = self._course_key_to_son(location.course_key)
    query['definition.children'] = unicode(location)
    if (revision == ModuleStoreEnum.RevisionOption.published_only):
        query['_id.revision'] = MongoRevisionKey.published
    def cache_and_return(parent_loc):
        parent_cache.set(unicode(location), parent_loc)
        return parent_loc
    parents = list(self.collection.find(query, {'_id': True}, sort=[SORT_REVISION_FAVOR_DRAFT]))
    if (len(parents) == 0):
        return cache_and_return(None)
    if (revision == ModuleStoreEnum.RevisionOption.published_only):
        if (len(parents) > 1):
            non_orphan_parents = self._get_non_orphan_parents(location, parents, revision)
            if (len(non_orphan_parents) == 0):
                return cache_and_return(None)
            if (len(non_orphan_parents) > 1):
                raise ReferentialIntegrityError(u'{}    parents    claim    {}'.format(len(parents), location))
            else:
                return cache_and_return(non_orphan_parents[0].replace(run=location.course_key.run))
        else:
            return cache_and_return(Location._from_deprecated_son(parents[0]['_id'], location.course_key.run))
    else:
        all_parents = []
        published_parents = 0
        for parent in parents:
            if (parent['_id']['revision'] is None):
                published_parents += 1
            all_parents.append(parent)
        if (published_parents > 1):
            non_orphan_parents = self._get_non_orphan_parents(location, all_parents, revision)
            return cache_and_return(non_orphan_parents[0].replace(run=location.course_key.run))
        found_id = all_parents[0]['_id']
        return cache_and_return(Location._from_deprecated_son(found_id, location.course_key.run))
