'Given a structure, builds block_key to parents mapping for all block keys in structure
and returns it
:param structure: db json of course structure
:return dict: a dictionary containing mapping of block_keys against their parents.'

def build_block_key_to_parents_mapping(self, structure):

    children_to_parents = defaultdict(list)
    for (parent_key, value) in structure['blocks'].iteritems():
        for child_key in value.fields.get('children', []):
            children_to_parents[child_key].append(parent_key)
    return children_to_parents
