rishabhdaim commented on code in PR #2447:
URL: https://github.com/apache/jackrabbit-oak/pull/2447#discussion_r2272801113


##########
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:
   @thomasmueller randomized test case has been added for this traversal order 
as well.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to