Fixed #17946 -- Fixed deserialization of self-referencing M2M fields

Thanks Philip Mountifield for the report and excellent analysis, and
Simon Charette for the review.