def get_recommendation_tree(data):
 recommendation_tree = {}
 for subtopic in data:
  recommendation_tree[str(subtopic)] = []
  related_subtopics = data[subtopic]['related_subtopics']
  for rel_subtopic in related_subtopics:
   if rel_subtopic:
    exercises = get_topic_contents(topic_id=rel_subtopic, kinds=['Exercise'])
    for ex in exercises:
     recommendation_tree[str(subtopic)].append(ex['id'])
 return recommendation_tree

def get_recommendation_tree ( data ) : recommendation_tree = { } for subtopic in data : recommendation_tree [ str ( subtopic ) ] = [ ] related_subtopics = data [ subtopic ] [ 'related_subtopics' ] for rel_subtopic in related_subtopics : if rel_subtopic : exercises = get_topic_contents ( topic_id = rel_subtopic , kinds = [ 'Exercise' ] ) for ex in exercises : recommendation_tree [ str ( subtopic ) ] . append ( ex [ 'id' ] ) return recommendation_tree
returns a dictionary of related exercises for each subtopic .