I think both work, but none are perfect. The problem is that my version cannot distinguish relations with the same name, and yours cannot distinguish multiple relations between the two same classes. 

So how about checking them all? I mean relation.name, relation.parent and relation.child