rewrite leetcode flatten binary tree to linked list