Reversing doubly-linked lists