ImmutableSortedMap<Integer, Bucket> lb = left.buckets().get();
ImmutableSortedMap<Integer, Bucket> rb = right.buckets().get();
TreeSet<Integer> availableIndexes = newTreeSet(union(lb.keySet(), rb.keySet()));
@Nullable
Bucket lbucket;
@Nullable
Bucket rbucket;
for (Integer index : availableIndexes) {
lbucket = lb.get(index);
rbucket = rb.get(index);
if (Objects.equal(lbucket, rbucket)) {
continue;
}
if (consumer.bucket(index.intValue(), bucketDepth, lbucket, rbucket)) {
RevTree ltree = lbucket == null ? RevTree.EMPTY : leftSource.getTree(lbucket.id());
RevTree rtree = rbucket == null ? RevTree.EMPTY : rightSource.getTree(rbucket.id());
traverseTree(consumer, ltree, rtree, bucketDepth + 1);
}
consumer.endBucket(index.intValue(), bucketDepth, lbucket, rbucket);
}
}