You could annotate this with the tail recursion flag `@tailrec`