```
vector<int> inorderTraversal(TreeNode *root) {
vector<int> output;
if (root == NULL)
return output;
stack <TreeNode *> nodeStack;
TreeNode *current;
nodeStack.push(root);
current = root;
while(1)
{
while(current->left){ // checking to the left;
nodeStack.push(current->left);
current = current->left;
}
TreeNode *node = nodeStack.top(); // the top one on the stack;
output.push_back(node->val); // get the value in the node;
nodeStack.pop();
if(node->right){
nodeStack.push(node->right);
current = node->right;
}
else{
if (nodeStack.empty() == true) return output;
while(!nodeStack.top()->right){
TreeNode *node = nodeStack.top(); // the top one on the stack;
output.push_back(node->val); // get the value in the node;
nodeStack.pop();
if (nodeStack.empty() == true) return output;
}
TreeNode *node = nodeStack.top(); // the top one on the stack;
output.push_back(node->val); // get the value in the node;
current = nodeStack.top()->right;
nodeStack.pop();
nodeStack.push(current);
}
}
}
```

The code has been accepted by OJ. The whole procedure is inspired by a standard iterative version of "Binary Tree Preoder Traversal". By using stack, it is easy to form the iterative method. Hoping somone could improve my version of "Inorder Traversal", making it more neat.