'Find all fields of type reference and convert the payload into UsageKeys
:param class_: the XBlock class
:param course_key: a CourseKey object for the given course
:param jsonfields: a dict of the jsonified version of the fields'

def _convert_reference_fields_to_keys(self, class_, course_key, jsonfields):

    result = {}
    for (field_name, value) in jsonfields.iteritems():
        field = class_.fields.get(field_name)
        if (field is None):
            continue
        elif (value is None):
            result[field_name] = value
        elif isinstance(field, Reference):
            result[field_name] = self._convert_reference_to_key(value)
        elif isinstance(field, ReferenceList):
            result[field_name] = [self._convert_reference_to_key(ele) for ele in value]
        elif isinstance(field, ReferenceValueDict):
            result[field_name] = {key: self._convert_reference_to_key(subvalue) for (key, subvalue) in value.iteritems()}
        else:
            result[field_name] = value
    return result
