def get_exercise_parents_lookup_table():
 global exercise_parents_lookup_table
 if exercise_parents_lookup_table:
  return exercise_parents_lookup_table
 tree = get_topic_nodes_with_children(parent='root')
 for topic in tree:
  for subtopic_id in topic['children']:
   exercises = get_topic_contents(topic_id=subtopic_id, kinds=['Exercise'])
   for ex in exercises:
    if (ex['id'] not in exercise_parents_lookup_table):
     exercise_parents_lookup_table[ex['id']] = {'subtopic_id': subtopic_id, 'topic_id': topic['id']}
 return exercise_parents_lookup_table

def get_exercise_parents_lookup_table ( ) : global exercise_parents_lookup_table if exercise_parents_lookup_table : return exercise_parents_lookup_table tree = get_topic_nodes_with_children ( parent = 'root' ) for topic in tree : for subtopic_id in topic [ 'children' ] : exercises = get_topic_contents ( topic_id = subtopic_id , kinds = [ 'Exercise' ] ) for ex in exercises : if ( ex [ 'id' ] not in exercise_parents_lookup_table ) : exercise_parents_lookup_table [ ex [ 'id' ] ] = { 'subtopic_id' : subtopic_id , 'topic_id' : topic [ 'id' ] } return exercise_parents_lookup_table
return a dictionary with exercise ids as keys and topic_ids as values .