Solve the flatten binary tree to singly linked list problem in leetcode.