protected E2 getChildOf(E1 parent) {
   Collection<? extends RefObject> c = super.query(true, parent);
   assert (c.size() <= 1);
   if (c.isEmpty()) {
     return null;
   } else {
     return end2GenericClass.cast(c.iterator().next());
   }
 }
 protected E1 getParentOf(E2 child) {
   Collection<? extends RefObject> c = super.query(false, child);
   assert (c.size() <= 1);
   if (c.isEmpty()) {
     return null;
   } else {
     return end1GenericClass.cast(c.iterator().next());
   }
 }