- Changed toHierarchy() to order nodes based on their index in the collect...

- Changed toHierarchy() to order nodes based on their index in the collection rather than their ID

The current functionality uses the ID of the node which often leads to incorrect order. Changing toHierarchy to work off the index at least lets the order be based on the current order of the collection. In truth it would probably make more sense to have the order be based off the "left" field... However, this is my solution for now and IMO an improvement on what it was.