goes through all the nodes