This procedure took a lot of effort to be understood, but now it seems quite easy.
Imagine we need to create a recursive m2m relationship, something like a "related posts" field assigned to a Post model. It would be nice if we could exclude the current editing post from the available choices.
This is quite straightforward if we go with the default select multiple widget. In fact we only need to create a custom form class and override the queryset property of the related_posts field in the
__init__ function, excluding the id of the current instance, and then assign such form class in the ModelAdmin class, see this SO question for more info.
But things become more ...