# Equality of joint distributions implies equality of conditional expectations in distribution

I'm trying to prove the following statement:

If \begin{equation*} \left( X_1, X_2, \ldots, X_n\right) \stackrel{D}{=}\left( X_1, Y_2, \ldots, Y_n\right) \end{equation*} then \begin{equation*} \mathbb{E}[X_1|X_2, \ldots, X_n]\stackrel{D}{=}\mathbb{E}[X_1|Y_2, \ldots, Y_n] \end{equation*}

I have tried to use the definition of conditional expectation but this has gotten me nowhere. Does anyone have any idea?

Notice that there exists a measurable function $g\colon \mathbb R^{n-1}\to\mathbb R$ such that $$\mathbb{E}\left[X_1|X_2, \ldots, X_n\right]=g\left(X_2,\dots,X_n\right)\mbox{a.s.},$$ by Doob-Dynkin's lemma. Similarly, there exists a measurable function $h\colon \mathbb R^{n-1}\to\mathbb R$ such that $$\mathbb{E}\left[X_1|Y_2, \ldots, Y_n\right]=h\left(Y_2,\dots,Y_n\right)\mbox{a.s.}$$ Let $B$ be a Borel subset of $\mathbb R^{n-1}$. Then, by assumption, $$\mathbb E\left[X_1\mathbb 1_{(X_2,\dots,X_n)\in B }\right]=\mathbb E\left[X_1\mathbb 1_{(Y_2,\dots,Y_n)\in B }\right],$$ and using the definition of conditional expectation $$\mathbb E\left[g\left(X_2,\dots,X_n\right)\mathbb 1_{(X_2,\dots,X_n)\in B }\right]=\mathbb E\left[h\left(Y_2,\dots,Y_n\right) \mathbb 1_{(Y_2,\dots,Y_n)\in B }\right].$$ Conclude by using the fact that $\left(X_2,\dots,X_n\right)$ has the same distribution as $\left(Y_2,\dots,Y_n\right)$.