This question has already been posed and aswered, but I think the proof proposed by @Brian M. Scott can be "simplified". If not, I would like to understand why. NOTE: I ask this question because @Brian M. Scott seems to be no more active on this site, so I can't get an answer from him.
I want to prove the following:
If $X$ is completely metrizable, and $A\subseteq X$ with $f:A\to A$ a homeomorphism, then there is a $G_\delta$ set $G\subseteq X$ containing $A$ and an extension $h:G\to G$ of $f$ which is a homeomorphism of $G$.
As I understand it, a proof goes as follows:
(1) there is (Lavrintiev's Theorem) an extension $f_0\colon G_0\to H_0$ where $G_0$, $H_0$ are $G_\delta$ containing $A$;
(2) Then, for every $n$, put $$f_{n+1}=f_n\upharpoonright (G_n\cap H_n)\colon G_n\cap H_n \to f_n(G_n\cap H_n)$$ homeo and let $G_{n+1}=G_n\cap H_n$ and $H_{n+1}=f_n(G_n\cap H_n)$.
If I argue correctly, $G\colon =\bigcap_{n\in\omega} G_n=\bigcap_{n\in\omega} (G_n\cap H_n)$ is obviously $G_\delta$ and contains $A$; moreover, $h=\bigcap_{n\in\omega} f_n$ is a homeo which equals $f$ on $A$ and $$h(G)=\bigcap_{n\in\omega} f_n(G_n)=\bigcap_{n\in\omega} G_{n+1}=G.$$
What I miss is why in the above answer the construction involves a distinction between even and odd numbers. Thank you in advance for you help.
Can someone give me a counterexample of why my attempt is wrong and the one be @Brian is correct, whenever it exists?