@pervognsen It's a cool trick. I hope this is correct. I don't bother with having the current version node point to the actual values array, it just makes things more complicated. Uses stackless traversal using pointer reversal for reroot, no recursion needed.
https://gist.github.com/mistymntncop/d2b54ef13911f5ef203f4160bfd06102
https://www.youtube.com/watch?v=gh2A7yFsBZ4
Allen's debut opening of his data structures series. Give it a watch.