> Why this? Isn't it more simple to flatten before calling?

You right, it should be.

> Explicit return type?

Ok, I'll add it.