check for cyclic linked lists