$idy is essentially an alias for the id generated from the result sql statement. I shift it to replace $root so that it becomes the iterator for the id comparisons. I've used it twice for clarity and I think I was having a problem using $id in my script because it's also used as a field in my data. $i is just a reference of ... oops I see that I should have used $i with my while rather than $idy.
I've spent a day familiarizing myself with DBIx::Tree::NestedSet but I can't figure out how to traverse the tree programmatically. It looks like it's not designed to populate the left and right ids!