Solution (source code)

= Solution

Let $g$ be an isometry of the <tree> $T$. After subdividing edges if necessary, it has no edge inversion. If $g$ fixes a vertex, it is an <elliptic isometry of a tree>. Otherwise choose a vertex $v$ minimizing the positive integer $d(v,gv)$. The geodesic segments $g^n[v,gv]$ concatenate without backtracking: any backtracking would produce a vertex with smaller displacement. Their union over $n\in\mathbb Z$ is therefore a bi-infinite geodesic, the <axis of a tree isometry>, and $g$ translates it by $d(v,gv)$. This proves the elliptic-hyperbolic classification of an <isometry of a tree>.

An element of finite order cannot translate a line through a positive distance, since its powers would have unbounded displacement. Every finite-order element of $SL_2(\mathbb Z)$ therefore fixes a vertex of its <Bass-Serre tree>. Vertex stabilizers are conjugates of $\langle A\rangle$ and $\langle B\rangle$, so the element is conjugate to a power of $A$ or a power of $B$.