I donot understand that how every node is returning to its root and finally to main root each time…plz explain me that logic and tell me that line of code which is doing this

i donot understand that how every node is returning to its root and finally to main root each time…plz explain me that logic and tell me that line of code which is doing this