reverse a doubly linked list in python