optimize codes for Populating-Next-Right-Pointers-in-Each-Node