A few operations on a singly linked list in Python