def map_references(value, field, actual_course_key):
 if (not value):
  return value
 if isinstance(field, Reference):
  return value.map_into_course(actual_course_key)
 if isinstance(field, ReferenceList):
  return [sub.map_into_course(actual_course_key) for sub in value]
 if isinstance(field, ReferenceValueDict):
  return {key: ele.map_into_course(actual_course_key) for (key, ele) in value.iteritems()}
 return value

def map_references ( value , field , actual_course_key ) : if ( not value ) : return value if isinstance ( field , Reference ) : return value . map_into_course ( actual_course_key ) if isinstance ( field , ReferenceList ) : return [ sub . map_into_course ( actual_course_key ) for sub in value ] if isinstance ( field , ReferenceValueDict ) : return { key : ele . map_into_course ( actual_course_key ) for ( key , ele ) in value . iteritems ( ) } return value
map the references in value to actual_course_key and return value .