int calcInheritenceChain(PersistentEntity pe) {
   if (pe == null) {
     return 0;
   } else {
     return calcInheritenceChain(pe.getParentEntity()) + 1;
   }
 }
 public PersistentEntity getRootEntity() {
   if (isRoot() || getParentEntity() == null) {
     return this;
   }
   PersistentEntity parent = getParentEntity();
   while (!parent.isRoot()) {
     parent = parent.getParentEntity();
   }
   return parent;
 }