When it is allowed to pull a r.v. out of the expectation, i.e.
$E(XY|Y)\overset?=YE(X|Y)\tag1$.
or even
$E(Y^2|Y)\overset?=Y^2\tag2$
in the computation rules it is written that if,
$XY\ge0$ or both r.v. are in $L^1(\star)$
it is allowed. But what if other conditions were given instead of $(\star)$, for example
$E(X^2|Y)=Y^2$ and $E(X|Y)=Y$
Is then $(1)\ \&\ (2)$ still valid ?
$$\mathbb E[X\mid \mathcal G]=X$$ when $X$ is $\mathcal G-$measurable. So obviously, for any Borel function, $$\mathbb E[f(Y)\mid Y]=f(Y).$$