Suppose there are 3 random variables $(X, Y, Z)$, such that $ Y \perp Z | X $ and $ X \perp Z | Y $.
I have convinced myself that it follows that $Z$ is independent of $X, Y$.
$$ p(X, Y, Z) = p(X) p(Y|X) p(Z|X) = p(X, Y) p(Z | X) $$ $$ p(X, Y, Z) = p(Y) p(X|Y) p(Z|Y) = p(X, Y) p(Z | Y) $$
Therefore $p(Z|X) = p(Z|Y)$ but the former is a function of $X$, the latter a function of $Y$, so it must be a constant i.e. $p(Z|X) = p(Z|Y) = p(Z)$.
Finally, plugging back in $$ p(X, Y, Z) = p(X) p(Y|X) p(Z|X) = p(X, Y) p(Z) $$
Is the above argument correct?
Is there a better/more general proof?