Geodesics that self-intersect at finitely many points Notations
$M$ will denote a smooth manifold and $\nabla$ an affine connection on it. A smooth curve $\gamma\colon I \to M$ will be called a geodesic if it is $\nabla$-parallel along itself, that is $\nabla_{\dot{\gamma}(t)}\dot{\gamma}=0$ for every $t \in I$. A geodesic will be said to be maximal if every proper extension of it is not a geodesic.

It is easy to find examples of maximal geodesics which do not self-intersect, like 
lines in Euclidean plane, or that intersect in infinitely many points, like great circles on the sphere. On the contrary I cannot find examples of geodesics which self-intersect at finitely many points, like the curve below: 


Question Is it possible to determine $M$ and $\nabla$ in such a way that one of the resulting maximal geodesics intersects at finitely many points?

Thank you. 
 A: I would like to give an answer with a certain mechanical flavor.
Let us consider the Lagrangian $L=K-V$ where $K=\dfrac{x'^2+y'^2}{2}$ and $V=\dfrac{x^2+ a^2y^2}{2},$ with $a\in\mathbb{R}_+,$ which describe a particle in the plane acted upon by a anisotropic spring.
The equations of motion are elementarly solved obtaining $$x=A\cos(t+\phi),\ y(t)=B\sin(at+\psi),$$ with $A,B,\phi,\psi$ arbitrary constants of integrations.
The trajectories of motion are the well-known Lissajous curves; if $a\in\mathbb{Q}$ then they are closed with multiple self-intersctions (see the figure below), otherwise they fill densely a domain of the plane.

Why does this argument answer you question?
By Maupertius' principle, for any $e>0,$ in the invariant submanifold $\Omega:=\{(x,y):V(x,y)<e\},$ the trajectories of motion coincide up to a reparametrization with the the geodesics for the Jacobi metric $g=(e-V)K$ on $\Omega.$
A: Take a quadrant of the plane and roll it up into a cone by gluing the two edges.
 
Shown above are the unfolding and the glued manifold, with a single geodesic shown in black; the "seam" runs down the right side of the cone in the right image. In fact, every geodesic that does not pass through the apex intersects itself exactly once.
For a smooth manifold, just round off the top.
