convert tree to linked list