Solution for finding the beginning of loop in list