The current code would fail when remove the root element in a tree where right subtree only have right child.
# 17
# 0 20
# -5 5 25
Current code would produce a result with duplicate elements
# 20
# 0 20
# -5 5 25
Trick is to move one the assignment to root value to the bottom