'For a given locator, look in the mapping table and see if it has been pinned
to a particular modulestore
If locator is None, returns the first (ordered) store as the default'

def _get_modulestore_for_courselike(self, locator=None):

    if (locator is not None):
        locator = self._clean_locator_for_mapping(locator)
        mapping = self.mappings.get(locator, None)
        if (mapping is not None):
            return mapping
        else:
            if isinstance(locator, LibraryLocator):
                has_locator = (lambda store: (hasattr(store, 'has_library') and store.has_library(locator)))
            else:
                has_locator = (lambda store: store.has_course(locator))
            for store in self.modulestores:
                if has_locator(store):
                    self.mappings[locator] = store
                    return store
    return self.default_modulestore
