'Compute the metadata inheritance for the course.'

def _get_cached_metadata_inheritance_tree(self, course_id, force_refresh=False):

    tree = {}
    course_id = self.fill_in_run(course_id)
    if (not force_refresh):
        if ((self.request_cache is not None) and (unicode(course_id) in self.request_cache.data.get('metadata_inheritance', {}))):
            return self.request_cache.data['metadata_inheritance'][unicode(course_id)]
        if (self.metadata_inheritance_cache_subsystem is not None):
            tree = self.metadata_inheritance_cache_subsystem.get(unicode(course_id), {})
        else:
            logging.warning('Running    MongoModuleStore    without    a    metadata_inheritance_cache_subsystem.    This    is                                                                                    OK    in    localdev    and    testing    environment.    Not    OK    in    production.')
    if (not tree):
        tree = self._compute_metadata_inheritance_tree(course_id)
        if (self.metadata_inheritance_cache_subsystem is not None):
            self.metadata_inheritance_cache_subsystem.set(unicode(course_id), tree)
    if (self.request_cache is not None):
        if ('metadata_inheritance' not in self.request_cache.data):
            self.request_cache.data['metadata_inheritance'] = {}
        self.request_cache.data['metadata_inheritance'][unicode(course_id)] = tree
    return tree
