detect loop in list then find the entry of loop