[java] How do implement a breadth first traversal?