Create belongs_many_many relation on self

I've been trying to create a $many_many / $belongs_many_many relation with self. I've come across several use cases for this, e.g. setting groups of related pages so I can add 'See also links' to pages, Properties that can be booked together etc.

I've gotten a has_many relation to work on self, but I would like the relation to be maintained on both ends. That is, if I set the checkbox on Page A that it is related to Page B, the checkbox for Page A should be automatically set for Page B (Just as it would work with other $belongs_many_many relations).

I've tried the code below (based on tutorial 5) where I want to set which modules are related (e.g. i18n and Translatable). My code only maintains the relation in one direction, the other side isn't maintained.