Deduplicate a doubly linked list