Thanks for the nice solution! Here is mine in C++.

class Solution {
public:
TreeNode* addOneRow(TreeNode* root, int v, int d) {
if (d == 1) {
TreeNode *p = new TreeNode(v);
p->left = root;
return p;
}
dfs(root, v, d-1);
return root;
}
private:
void dfs(TreeNode* p, int v, int d) {
if (p == nullptr) return;
if (d == 1) {
TreeNode *pl = new TreeNode(v), *pr = new TreeNode(v);
pl->left = p->left;
pr->right = p->right;
p->left = pl;
p->right = pr;
}
else {
dfs(p->left, v, d-1);
dfs(p->right, v, d-1);
}
}
};