deduplicate a linked list