Scala tail-recursive path finding