improve flatten binary tree to linked list solution