protected BaseType transformChildren(PartialFunction<BaseType, BaseType> f,
                                         BiFunction<BaseType, PartialFunction<BaseType, BaseType>, BaseType> nextOperation) {
        ArrayList<BaseType> newChildren = new ArrayList<>();
        boolean updated = false;
        for (BaseType child : children()) {
            BaseType newChild = nextOperation.apply(child, f);
            if (!child.fastEquals(newChild)) {
                updated = true;
            }
            if (newChild != null) {
                newChildren.add(newChild);
            }
        }
        if (updated) {
            return withNewChildren(newChildren);
        } else {
            return (BaseType) this;
        }
    }
Collect the elements produced by `f` and not null.
indexr-query-opt/src/main/java/io/indexr/query/TreeNode.java