I\'m trying to find a way to typesafe a recursion (which returns a number by the end) using generics.
What I tried: