private static <T> Stream.Builder<? extends T> traverse(
            T first, 
            Function<T, Stream<? extends T>> traverser, 
            TraversalOrder traversalOrder, 
            Stream.Builder<T> builder) {
        
        requireNonNulls(first, traverser, traversalOrder, builder);
        
        if (first == null) {
            return builder;
        }
        
        if (traversalOrder == TraversalOrder.DEPTH_FIRST_PRE) {
            builder.add(first);
        }
        
        final Stream<? extends T> next = traverser.apply(first);
        if (next != null) {
            next.filter(Objects::nonNull)
                .forEach((T n) -> traverse(n, traverser, traversalOrder, builder));
        }
        
        if (traversalOrder == TraversalOrder.DEPTH_FIRST_POST) {
            builder.add(first);
        }
        
        return builder;
    }
The walking order of the tree.
runtime-parent/runtime-config/src/main/java/com/speedment/runtime/config/internal/util/Trees.java