### Question:
DisplayHierarchyNode { public boolean isLoop() { return (parent() != null) ? parent().findAncestor( rdfNode() ) : false; } DisplayHierarchyNode( PropertyPath pathTo, DisplayHierarchyNode parent,
                                 DisplayRdfNode rdfNode, ShortNameRenderer shortNameRenderer ); PropertyPath pathTo(); RDFNodeWrapper terminalLink(); boolean isOnExplicitPath(); Set<PropertyPath> explicitPaths(); DisplayHierarchyNode parent(); boolean isRoot(); DisplayRdfNode rdfNode(); boolean isLoop(); boolean findAncestor( DisplayRdfNode resource ); boolean isLeaf( DisplayHierarchyContext context ); List<DisplayHierarchyNode> children(); void addSibling( DisplayHierarchyNode sibling ); List<DisplayHierarchyNode> siblings(); boolean hasSiblings(); void addHint( String hint ); String hintsString(); boolean hasHint( String hint ); boolean isSimpleResource(); String relatedLinksHTML(); List<Link> relatedLinks(); boolean hasAllProperties( Object... properties ); boolean hasAllProperties( List<Object> properties ); void pullToStart( Object... properties ); void pullToStart( List<Object> properties ); List<DisplayHierarchyNode> extractByPredicate( Object... properties ); List<DisplayHierarchyNode> extractByPredicate( List<Object> properties ); boolean isResource(); boolean isLiteral(); boolean isAnon(); boolean isList(); String getLexicalForm(); String getName(); Object getValue(); String getURI(); @Override String toString(); static final String SORT_BY_FORMAT; static final int MAX_RELATED_LINK_LABEL_LENGTH; }### Answer:
@Test public void testIsLoop() { Resource r0 = ResourceFactory.createResource( "http: Resource r1 = ResourceFactory.createResource( "http: Resource r2 = ResourceFactory.createResource( "http: DisplayHierarchyNode c0 = new DisplayHierarchyNode( new PropertyPath(), dhn, new DisplayRdfNode( rm.page(), r0 ), null ); DisplayHierarchyNode c1 = new DisplayHierarchyNode( new PropertyPath(), c0, new DisplayRdfNode( rm.page(), r1 ), null ); DisplayHierarchyNode c2 = new DisplayHierarchyNode( new PropertyPath(), c1, new DisplayRdfNode( rm.page(), r2 ), null ); DisplayHierarchyNode c3 = new DisplayHierarchyNode( new PropertyPath(), c1, new DisplayRdfNode( rm.page(), r0 ), null ); assertFalse( dhn.isLoop() ); assertFalse( c0.isLoop() ); assertFalse( c1.isLoop() ); assertFalse( c2.isLoop() ); assertTrue( c3.isLoop() ); assertTrue( c0.findAncestor( new DisplayRdfNode( rm.page(), r0 ) )); assertTrue( c1.findAncestor( new DisplayRdfNode( rm.page(), r0 ) )); assertTrue( c2.findAncestor( new DisplayRdfNode( rm.page(), r0 ) )); assertFalse( c1.findAncestor( new DisplayRdfNode( rm.page(), r2 ) )); }