cpp implementation of Flatten Binary Tree to Linked List