void populate(TreeLinkNode* root)
{
while(root)
{
TreeLinkNode* pre=nullptr;
TreeLinkNode* next=nullptr;
for(;root;root=root->next)
{
if(!next)
next=root->left?root->left:root->right;
if(root->left!=nullptr)
{
if(pre)pre->next=root->left;
pre=root->left;
}
if(root->right!=nullptr)
{
if(pre)pre->next=root->right;
pre=root->right;
}
}
root=next;
}