Group foreign relations by property type

@alexef @iuliachiriac please review
You can use `.setdefault` on result.