My neat solution in C++
vector<vector<int> > levelOrder(TreeNode *root) {\n    \tvector<vector<int> > retVal;\n\n    \tlevelOrder(root, retVal, 0);\n\n    \treturn retVal;\n    }\n\n  
    vector<vector<int> > levelOrder(TreeNode *root) {\n    \tvector<vector<int> > retVal;\n\n    \tlevelOrder(root, retVal, 0);\n\n    \treturn retVal;\n    }\n\n    void levelOrder(TreeNode* root, vector<vector<int> > &v, int currLevel) {\n    \tif (root == NULL) {\n    \t\treturn;\n    \t}\n\n    \tif (v.empty() || currLevel > (v.size() - 1)) {\n    \t\tv.push_back(vector<int>());\n    \t}\n\n    \tv[currLevel].push_back(root->val);\n\n    \tlevelOrder(root->left, v, currLevel + 1);\n    \tlevelOrder(root->right, v, currLevel + 1);\n    }
[]