<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _serialize_to_one(self, key, val, rlink):
 """ Make a to_one JSON API compliant :spec: jsonapi.org/format/#document-resource-object-relationships :param key: the string name of the relationship field :param val: dict containing `rid` & `rtype` keys for the to_one & None if the to_one is null :return: dict as documented in the spec link """


        data = None
        if val and val['rid']:
            data = {'id': val['rid'], 'type': val['rtype']}

        return {
            key: {
                'data': data,
                'links': {
                    'related': rlink + '/' + key
                }
            }
        }