### Question:
Traversals { public static Node findParentWithRank(Node start, Rank rank) { try(ResourceIterator<Node> parents = Traversals.PARENTS.traverse(start).nodes().iterator()) { while (parents.hasNext()) { Node p = parents.next(); if ((int)p.getProperty(NeoProperties.RANK, -1) == rank.ordinal()) { return p; } } } return null; }  static Node findParentWithRank(Node start, Rank rank); static final TraversalDescription PARENT; static final TraversalDescription PARENTS; static final TraversalDescription LINNEAN_PARENTS; static final TraversalDescription CHILDREN; static final TraversalDescription SYNONYMS; static final TraversalDescription ACCEPTED; static final TraversalDescription PARENTS_AND_ACCEPTED; static final TraversalDescription BASIONYM_GROUP; static final TraversalDescription ACCEPTED_TREE; static final TraversalDescription TREE_WITHOUT_PRO_PARTE; static final TraversalDescription TREE; static final TraversalDescription DESCENDANTS; static final TraversalDescription SORTED_TREE; static final TraversalDescription SORTED_TREE_WITHOUT_PRO_PARTE; static final TraversalDescription SORTED_ACCEPTED_TREE; }### Answer:
@Test public void testFindParents() { try (Transaction tx = db.beginTx()) { root = createNode(Rank.KINGDOM, Labels.ROOT); Node p = root; for (Rank r : Rank.values()) { if (Rank.KINGDOM.higherThan(r) && r.higherThan(Rank.FORM)) { Node child = createNode(r, Labels.TAXON); p.createRelationshipTo(child, RelType.PARENT_OF); p = child; if (r == Rank.ORDER) { child1 = child; } else if (r == Rank.VARIETY) { child2 = child; } Node child2 = createNode(r, Labels.TAXON); p.createRelationshipTo(child2, RelType.PARENT_OF); } } tx.success(); } try (Transaction tx = db.beginTx()) { assertNull(Traversals.findParentWithRank(child1, Rank.SPECIES)); assertNull(Traversals.findParentWithRank(child1, Rank.FAMILY)); assertNull(Traversals.findParentWithRank(child1, Rank.ORDER)); assertEquals(root, Traversals.findParentWithRank(child1, Rank.KINGDOM)); assertEquals(Rank.SUBCLASS.ordinal(), Traversals.findParentWithRank(child1, Rank.SUBCLASS).getProperty(NeoProperties.RANK)); assertNull(Traversals.findParentWithRank(child2, Rank.UNRANKED)); assertNull(Traversals.findParentWithRank(child1, Rank.ORDER)); assertEquals(root, Traversals.findParentWithRank(child2, Rank.KINGDOM)); } }