'Get the structure from the persistence mechanism whose id is the given key.
This method will use a cached version of the structure if it is available.'

def get_structure(self, key, course_context=None):

    with TIMER.timer('get_structure', course_context) as tagger_get_structure:
        cache = CourseStructureCache()
        structure = cache.get(key, course_context)
        tagger_get_structure.tag(from_cache=str(bool(structure)).lower())
        if (not structure):
            tagger_get_structure.sample_rate = 1
            with TIMER.timer('get_structure.find_one', course_context) as tagger_find_one:
                doc = self.structures.find_one({'_id': key})
                if (doc is None):
                    log.warning('doc    was    None    when    attempting    to    retrieve    structure    for    item    with    key    %s', unicode(key))
                    return None
                tagger_find_one.measure('blocks', len(doc['blocks']))
                structure = structure_from_mongo(doc, course_context)
                tagger_find_one.sample_rate = 1
            cache.set(key, structure, course_context)
        return structure
