I am trying to solve the above question. We start from $X_0 = 1 $. Since we only conditioning on the first step, so $X_1$ is either $2$ or $0$.
For $X_1=0$, we will have $E(Z^1) = z$ and for $X_1=2$, we have $E(Z^{1+T'})$ = $z G(Z)$
So we will have $G(Z) = z(1-p) + zG(z)p $
Can anyone tell me what did i do wrong or explain what make $pzG(z)^2 - G(z) + (1-p)z$ in the question?
Thanks

$E[z^{T_x}|X_1 = 0] = E[z^1] = z$.
$E[z^{T_x}|X_1 = 2] = E[z^{T_x+1}|X_0 = 2] = zE[z^{T_x}|X_0 = 2] = zG(z)^2$. I justify the final inequality by saying that to hit zero from $X_0 = 2$, we have to hit $1$ from $X_0 = 2$, and then hit $0$ from $X_{T_x'} = 1$, which by symmetry is the same as $E[z^{T_x}]^2$.
By the tower property,
$G(z) = E[z^{T_x}] = (1-p)E[z^{T_x}|X_1 = 0]+pE[z^{T_x}|X_1 = 2] = (1-p)z+pzG(z)^2$
Hence $pzG(z)^2-G(z)+(1-p)z=0$