private static <T, B> void copy(
		final Tree<? extends T, ?> source,
		final TreeNode<B> target,
		final Function<? super T, ? extends B> mapper
	) {
		for (int i = 0; i < source.childCount(); ++i) {
			final var child = source.childAt(i);
			final TreeNode<B> targetChild = of(mapper.apply(child.value()));
			target.attach(targetChild);
			copy(child, targetChild, mapper);
		}
	}
Return a new {@code TreeNode} from the given source {@code tree}. The
whole tree is copied.

@param tree the source tree the new tree-node is created from
@param mapper the tree value mapper function
@param <T> the current tree value type
@param <B> the mapped tree value type
@return a new {@code TreeNode} from the given source {@code tree}
@throws NullPointerException if one of the arguments is {@code null}
jenetics.ext/src/main/java/io/jenetics/ext/util/TreeNode.java