Some recursive problems with Scala