Linked list loop detection and removal example