EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { public EntityReference getRoot() { EntityReference reference = this; while (reference.getParent() != null) { reference = reference.getParent(); } return reference; } EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); void setName(String name); String getName(); void setParent(EntityReference parent); EntityReference getParent(); void setChild(EntityReference child); EntityReference getChild(); void setType(EntityType type); EntityType getType(); EntityReference getRoot(); EntityReference extractReference(EntityType type); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override EntityReference clone(); int compareTo(EntityReference reference);  }
@Test public void testGetRoot() { EntityReference reference = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); Assert.assertEquals(new EntityReference("wiki", EntityType.WIKI), reference.getRoot()); }