@Override public Node traverse(SelectorLeaf selector) { Node secondNode = selector.traverse(baseContext); Set<Tally> tallies = new HashSet<Tally>(); tallies.addAll(firstNode.getTallies()); tallies.retainAll(secondNode.getTallies()); assert tallies.isEmpty() || tallies.size() == 1; if (tallies.isEmpty()) { Tally tally = newTally(firstNode, secondNode); firstNode.addTally(tally); secondNode.addTally(tally); return tally.getNode(); } else { return tallies.iterator().next().getNode(); } }
@Override public Node traverse(SelectorLeaf selector) { return selector.traverse(this); }