```
int kthSmallest(struct TreeNode* root, int k) {
struct TreeNode* stack[1000];
int count = 0, top = 0;
while(count < k) {
if (root != NULL) {
stack[top++] = root;
root = root->left;
}
else {
root = stack[--top];
count++;
root = root->right;
}
}
return stack[top]->val;
}
```

but when I use the Testcases as follows:

```
[1,2,3,4]
1/2/3/4 // four values of k
```

the Output squence is 4/2/1/3. But it should be 1/2/3/4, isn't it? : (