Detect a loop in a linked list