thomasmueller commented on code in PR #2447: URL: https://github.com/apache/jackrabbit-oak/pull/2447#discussion_r2272793337
########## oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/Traverser.java: ########## @@ -169,5 +167,107 @@ public T next() { return current; } } + + /** + * Returns an iterator that traverses a tree structure in post-order. Null nodes are strictly forbidden. + * <p> + * In post-order traversal, all children of a node are visited from left to right, followed by + * the node itself. This creates a bottom-up traversal pattern where leaf nodes are visited first, + * then their parents, and finally the root. + * + * @param <T> the type of value in the tree nodes + * @param root the root node of the tree, may be null + * @param childExtractor function to extract children from a node, must not be null + * @return an iterator that traverses the tree in post-order + * @throws NullPointerException if childExtractor or any child is null + */ + public static <T> FluentIterable<T> postOrderTraversal(final T root, final @NotNull Function<T, Iterable<? extends T>> childExtractor) { + Objects.requireNonNull(childExtractor, "Children extractor function must not be null"); + if (root == null) { + return FluentIterable.empty(); + } Review Comment: (I don't know if it should or should not throw in this specific case...) I think it would be good to have a randomized test case where we can compare the exact behavior of the old vs the new implementation. Specially edge cases like this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org