an exercise in deduplicating a linked list