Linked list and tree problems