hasLoop for linkedlist