void () { List<Integer> result = new ArrayList<>(); TreeTraversal.TracingIt<List<Integer>> it = TreeTraversal.TRACING_BFS.traversal((Function<List<Integer>, Iterable<List<Integer>>>)integers -> JBIterable.from(integers).skip(1).transform(WRAP_TO_LIST)).fun(new SmartList<>(1)).typedIterator(); while (it.advance()) { Integer cur = it.current().get(0); result.add(cur); assertEquals(JBIterable.generate(cur, DIV_2).takeWhile(IS_POSITIVE).toList(), it.backtrace().transform(integers -> integers.get(0)) .toList()); if (cur > 4) continue; it.current().add(cur*2); it.current().add(cur*2); } assertEquals(JBIterable.of(1, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8).toList(), result); }