posted 5 years ago
The only way to perform a level-order traversal properly is to enqueue the nodes that you still need to traverse. To do this, you need to write a custom spliterator that manipulates the queue of nodes that need to be traversed:
It's not pretty, but it does the job cleanly and efficiently.