List<Integer> (TreeTraversal traversal) { List<Integer> result = new ArrayList<>(); Function<List<Integer>, Iterable<List<Integer>>> function = integers -> JBIterable.from(integers).skip(1).transform(WRAP_TO_LIST); JBIterable<List<Integer>> iter = traversal.traversal(function).fun(new SmartList<>(1)); for (List<Integer> integers : iter) { Integer cur = integers.get(0); result.add(cur); if (cur > 4) continue; integers.add(cur*2); integers.add(cur*2); } return result; }