flatten a binary tree to a linked list