Visited classes will be saved in the getClass method, so an infinite loop won't when there is a cyclic relationship between classes.