Solution (source code)

= Solution

The equation fails for general nonnested sigma-algebras. On the four-point space $\Omega=\{1,2,3,4\}$ with uniform probability, let
$$
A=\{1,2\},\qquad B=\{1,2,3\},
\qquad \mathcal G=\sigma(A),\qquad\mathcal H=\sigma(B),
$$
and take $X=\mathbf1_A$. The intersection $\mathcal G\cap\mathcal H$ is trivial, so
$$
\mathbb E[X\mid\mathcal G\cap\mathcal H]=\frac12.
$$
But $X$ is $\mathcal G$-measurable and
$$
\mathbb E[\mathbb E[X\mid\mathcal G]\mid\mathcal H]
=\mathbb E[X\mid\mathcal H]
=\frac23\mathbf1_B,
$$
which is zero on $B^c$ and is not almost surely $1/2$. This exhibits the failure of <iterated conditional expectation over nonnested sigma-algebras>.