Set<GraphNode> processed = new HashSet<GraphNode>();
while (!ancestorQueue.isEmpty()) {
GraphNode ancestor = ancestorQueue.poll();
Iterator<GraphEdge> edges = ancestor.getEdges(Direction.OUT);
while (edges.hasNext()) {
GraphEdge relationship = edges.next();
GraphNode parentNode = relationship.getToNode();
if (theirSet.contains(parentNode)) {
if (!processed.contains(parentNode)) {
ancestorQueue.add(parentNode);
processed.add(parentNode);
}