type node struct { lt *node gt *node key int } func reroot(to, from *node) { var ( lt = &to.lt gt = &to.gt key = to.key ) for from != nil { if from.key > key { *lt = from lt = &from.gt from = from.gt continue } *gt = from gt = &from.lt from = from.lt } *lt = nil *gt = nil }
To receive a hint, submit unfixed code.