<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def related_records2marc(self, key, value):
 """Populate the ``78708`` MARC field Also populates the ``78002``, ``78502`` MARC fields through side effects. """

    if value.get('relation_freetext'):
        return {
            'i': value.get('relation_freetext'),
            'w': get_recid_from_ref(value.get('record')),
        }
    elif value.get('relation') == 'successor':
        self.setdefault('78502', []).append({
            'i': 'superseded by',
            'w': get_recid_from_ref(value.get('record')),
        })
    elif value.get('relation') == 'predecessor':
        self.setdefault('78002', []).append({
            'i': 'supersedes',
            'w': get_recid_from_ref(value.get('record')),
        })
    else:
        raise NotImplementedError(u"Unhandled relation in related_records: {}".format(value.get('relation')))