def object_to_relations(o, e):
    # process forward and reverse references, so just loop over all the objects of the event
    if 'Object' in e['Event']:
        for eo in e['Event']['Object']:
            if 'ObjectReference' in eo:
                for ref in eo['ObjectReference']:
                    # we have found original object. Expand to the related object and attributes
                    if eo['uuid'] == o['uuid']:
                        # the reference is an Object
                        if ref.get('Object'):
                            # get the full object in the event, as our objectReference included does not contain everything we need
                            sub_object = get_object_in_event(ref['Object']['uuid'], e)
                            yield object_to_entity(sub_object, link_label=ref['relationship_type'])
                        # the reference is an Attribute
                        if ref.get('Attribute'):
                            ref['Attribute']['event_id'] = ref['event_id']   # LATER remove this ugly workaround - object can't be requested directly from MISP using the uuid, and to find a full object we need the event_id
                            for item in attribute_to_entity(ref['Attribute'], link_label=ref['relationship_type']):
                                yield item

                    # reverse-lookup - this is another objects relating the original object
                    if ref['referenced_uuid'] == o['uuid']:
                        yield object_to_entity(eo, link_label=ref['relationship_type'], link_direction=LinkDirection.OutputToInput)