OntologyTerms { public static <O extends Ontology> void visitParentsOf( TermId termId, O ontology, TermVisitor<O> termVisitor) { BreadthFirstSearch<TermId, IdLabeledEdge> bfs = new BreadthFirstSearch<>(); DefaultDirectedGraph<TermId, IdLabeledEdge> graph = ontology.getGraph(); bfs.startFromForward( graph, termId, new VertexVisitor<TermId, IdLabeledEdge>() { @Override public boolean visit(DefaultDirectedGraph<TermId, IdLabeledEdge> g, TermId v) { return termVisitor.visit(ontology, v); } }); }  static void visitChildrenOf(
    TermId termId, O ontology, TermVisitor<O> termVisitor); static Set<TermId> childrenOf(TermId termId, O ontology); static void visitParentsOf(
    TermId termId, O ontology, TermVisitor<O> termVisitor); static Set<TermId> parentsOf(TermId termId, O ontology);  }
@Test void testVisitParentsOf() { Set<TermId> parents = new TreeSet<>(); OntologyTerms.visitParentsOf( idBlueCarrot, ontology, (ontology, termId) -> { parents.add(termId); return true; }); assertEquals( ImmutableSet.of( TermId.of("VO:0000001"), TermId.of("VO:0000002"), TermId.of("VO:0000004"), TermId.of("VO:0000007")), parents); }