How can I still get the reference to a related item from within the source item or from the relationship itself when deleting the item?

In the project we have an item A related to different items B using a relationship C.

When attaching one of the B items to the A item, the B item updated one its attributes to reference the A item, in order to show in B one of the properties from A. To achieve this update I have created a method that copies the reference from A into the attribute from B, on the event onAfterAdd.

But when removing that relationship B from A I want to remove that reference to A in the attribute from B. In any of the onXXXDelete events, I can still find the source_id but there is no way to retrieve the related_id, so during the event operation I have lost any reference to the B item.

Is there an easy way to get that related_id of B item?

I have done an implementation that maybe it's too complex to achieve this functionality.

Or if there is another way to keep the reference in B from A instead of copying the A.id into an attribute from B, I'm open to liste to it.

Thanks and Regards