```
class Solution {
public:
void connect(TreeLinkNode *root) {
if (root==NULL)
return;
if (root->left==NULL)//no more children
return;
if (root->next!=NULL){
root->right->next=root->next->left;
}
root->left->next=root->right;
connect(root->left);
connect(root->right);
}
};
```