mapValues

fun <T, R> TreeNode<T>.mapValues(transform: (T) -> R): TreeNode<R>(source)

Returns a new tree with the same shape whose values are produced by transform. The original is left untouched. Stack-safe (iterative), so it handles arbitrarily deep trees.