static <T, U> Node<U> apply(Node<T> node, Function<? super T, ? extends U> mapper) { final U value = mapper.apply(node.getValue()); final List<Node<U>> children = node.getChildren().map(child -> Map.apply(child, mapper)); return new Node<>(value, children); }