Maybe the argument from the link that OP included can be mimicked: reducing the problem to complex Nullstellensatz with a bit of analysis. Consider a non-singlular point $\mathbf{p}\in Z$ near which the equation $Q(x_1,\dots,x_n)=0$ can be solved for one of the coordinates, say $x_n$. Hence there exists an open neighborhood $U$ of $\mathbf{p}=(p_1,\dots,p_{n-1},p_n)$ in $\Bbb{C}^n$ and a complex analytic function $\gamma$ with $$ \forall (x_1,\dots,x_n)\in U: Q(x_1,\dots,x_{n-1},x_n)=0 \Leftrightarrow x_n=\gamma(x_1,\dots,x_{n-1}). $$ The assumption on $P$ now shows that $P(x_1,\dots,x_{n-1},\gamma(x_1,\dots,x_{n-1}))=0$ whenever all the arguments are real numbers. But since $\mathbf{p}\in\Bbb{R}^n$ and $Q$ has real coefficients, all coefficients of the Taylor expansion of $\gamma$ at $(p_1,\dots,p_{n-1})$ are real. Therefore, all Taylor coefficients of $P(x_1,\dots,x_{n-1},\gamma(x_1,\dots,x_{n-1}))$ at $(p_1,\dots,p_{n-1})$ are real too. But the latter function is identically zero when $(x_1,\dots,x_{n-1})$ comes from a small enough neighborhood of $(p_1,\dots,p_{n-1})$ in $\Bbb{R}^{n-1}$, because then $(x_1,\dots,x_{n-1},\gamma(x_1,\dots,x_{n-1}))\in Z$. Therefore all Taylor coefficients of $P(x_1,\dots,x_{n-1},\gamma(x_1,\dots,x_{n-1}))$ at $(p_1,\dots,p_{n-1})$ are zero. In particular, this quantity is zero as $(x_1,\dots,x_{n-1})$ varies in a small enough neighborhood of $(p_1,\dots,p_{n-1})$ in $\Bbb{C}^{n-1}$. We conclude that there is a perhaps smaller open neighborhood $U'\subseteq U$ of $\mathbf{p}$ in $\Bbb{C}^n$ such that $P$ vanishes on the non-empty open subset $$ U'\cap\{(x_1,\dots,x_n)\in\Bbb{C}^n\mid Q(x_1,\dots,x_n)=0\} $$ of the complex zero locus. Therefore, $P$ must be zero on the entirety of $\{(x_1,\dots,x_n)\in\Bbb{C}^n\mid Q(x_1,\dots,x_n)=0\}$ (maybe some connectedness property is needed here).