public <A> List<A> collect(Function<BaseType, A> f) {
        ArrayList<A> list = new ArrayList<>();
        this.foreach(node -> {
            A res = f.apply(node);
            if (res != null) list.add(res);
        });
        return list;
    }
Collect the elements produced by `f` and not null.
indexr-query-opt/src/main/java/io/indexr/query/TreeNode.java