Correctly append/prepend subnets to path

Also, reverse the subnet array as needed
Replace subnet rbtree with sorted array