Detection for loop in singly linked list