Finitely generated group with subexponential growth and surjection onto $\mathbb{Z}$ has finitely generated kernel. I am trying to solve exercise 6.E.20 from the book of Clara Löh on Geometric Group Theory.

Let $G$ be a finitely
generated group with subexponential growth that admits a surjective homomorphism $\pi:G\rightarrow\mathbb{Z}$.  Show that then the kernel of $\pi$ is also finitely
generated.

I am still missing the part where you use the fact that $G$ has subexponential growth.
Take $T$ a finite generating set of $G$ and take $g\in G$ such that $\pi(g)= 1$. For any $t\in T$, if $\pi(t)=n$, we can write $t=tg^{-n}\cdot g^n$. Since $\pi(tg^{-n})=0$, we can find finite $S\subset\operatorname{ker}\pi$ such that $S\cup \{g\}$ generates $G$.
Now take $x=t_1t_2\ldots t_k\in\operatorname{ker}\pi$ with $t_i\in T$. This can be rewritten as $$x= {t_1g^{-n_1}}g^{n_1}{t_2g^{-n_2}}g^{-n_1}g^{n_1+n_2}{t_3g^{-n_3}}g^{-n_1-n_2}\cdots 
        g^{n_1+\cdots+n_{k-1}}{t_kg^{-n_k}}g^{-n_1-\cdots -n_{k-1}}{g^{n_1+\cdots+n_k}}$$
$$={t_1g^{-n_1}}\cdot g^{n_1}{t_2g^{-n_2}}g^{-n_1}\cdot g^{n_1+n_2}{t_3g^{-n_3}}g^{-n_1-n_2}\cdots 
        g^{n_1+\cdots+n_{k-1}}{t_kg^{-n_k}}g^{-n_1-\cdots -n_{k-1}}$$
Here, $n_i = \pi(t_i)$ and the final factor vanishes since $n_1+n_2+\cdots+n_k=0$ because $x\in\operatorname{ker}\pi$. We have shown that every element in the kernel is generated by the set $\{g^nsg^{-n}\mid s\in S\}$. Now Löh claims that this $n$ must be bounded and hence that the kernel is finitely generated.
I feel like this is a consequence of the subexponential growth but I cannot make this rigorous.
Subexponential growth means that for a generating set $T$, the growth function does not quasi-dominate an exponential.
The same question has been asked here, but it gives another proof method which is less direct.
 A: Let $K=\ker \pi$ and, as in your post,  let $G = \langle S, g \rangle$, with $S$ a finite subset of $K$. Then $K = \langle g^i S g^{-i} : i \in {\mathbb Z} \rangle$.
For $N \ge 0$, let $K_N = \langle g^i S g^{-i}  : 0 \le i \le N \rangle$, and for $N \le 0$ let $K_N = \langle g^{-i} S g^i : 0 \le i \le -N \rangle$.
So we have two ascending chains of subgroups of $K$:  $K_0 \le K_1 \le K_2 \le \cdots$ and $K_0 \le K_{-1} \le K_{-2} \le \cdots $.
If both of these chains stabilize after finitely many steps, then $K$ is generated by a finite number of the $K_i$ and hence $K$ is finitely generated, and we are done. So we can assume that one of them does not stabilize, and by swapping $g$ and $g^{-1}$ if necessary, we can assume that $K_0 \le K_1 \le K_2 \le \cdots$ does not stabilize.
Suppose that, for some $s \in S$ and $N_s  > 0$, we have $$g^{N_s} s g^{-N_s} \in \langle s,gsg^{-1},\ldots,g^{N_s-1}sg^{-(N_s-1)} \rangle.$$ Then the same condition holds for all $N \ge N_s$.
If such an $N_s$ existed for all $s \in S$, then the condition would hold for all $N \ge \max(N_s)$ and all $s \in S$. But then we would have $K_n \le K_{n-1}$ for all $n \ge \max(N_s)$, and the chain $K_0 \le K_1 \le K_2 \le \cdots$ would stabilize, contrary to assumption.
So there exists $s \in S$, such that $g^n s g^{-n} \notin \langle s, gsg^{-1},\ldots, g^{n-1}sg^{-(n-1)} \rangle$ for all $n > 0$.
We claim that the subsemigroup of $G$ generated by $gs$ and $g^2$ is free, which implies that $G$ has exponential growth.
If not then let $w_1$ and $w_2$ be distinct  (positive) words in $g^2$ and $gs$ of smallest total length such that $w_1 =_G w_2$. Then one of $w_1,w_2$ - say $w_1$ - must end in $gs$ and the other in $g^2$, since otherwise we could cancel the final letters and get shorter equal words.
Now, since $\pi(w_1) = \pi(w_2)$, they must both contain the same number of occurrences of $g^2$ and of $gs$ - suppose there is a total of $n$ occurrences of $g$ in both words.
Then, when we rewrite $w_1$ and $w_2$ in $G$ to collect the powers of $g$ to the right (as you have done in your post), we get $w_1' g^{n} = w_2'g^n$, where $w_1'$ and $w_2'$ are words in conjugates $g^ksg^{-k}$ of $s$ for $k \ge 0$.
Since $w_1$ ends in $gs$, and $w_2$ ends in $g^2$, the largest such $k$ occurring in $w_1'$ will be $g^nsg^{-n}$ at the end of $w'$, but the largest $k$ in $w_2$ will be less than $n$. So we get $g^n s g^{-n} \in \langle s, gsg^{-1},\ldots, g^{n-1}sg^{-(n-1)} \rangle$, contrary to assumption.
