List<Node> leftNodes = nodesByBucket.get(bucketIndex);// never returns null, but empty
if (null == rightBucket) {
traverseLeafLeaf(consumer, leftNodes.iterator(), Iterators.<Node> emptyIterator());
} else if (leftNodes.isEmpty()) {
if (consumer.bucket(bucketIndex, bucketDepth, null, rightBucket)) {
RevTree rightTree = (RevTree) bucketTrees.get(rightBucket.id());
// traverseBucketBucket(consumer, RevTree.EMPTY, rightTree, bucketDepth);
traverseTree(consumer, RevTree.EMPTY, rightTree, bucketDepth + 1);
}
consumer.endBucket(bucketIndex, bucketDepth, null, rightBucket);
} else {
RevTree rightTree = (RevTree) bucketTrees.get(rightBucket.id());
if (rightTree.buckets().isPresent()) {
traverseLeafBucket(consumer, leftNodes.iterator(), rightTree, bucketDepth + 1);
} else {
traverseLeafLeaf(consumer, leftNodes.iterator(), rightTree.children());
}
}
}
}