Reimplemented setting the next sibling node for the new online judge and remove some unnecessary checking for leaf nodes.