What's wrong with 'global' fields? I have a specialized class that handles this case without passing arguments at each call.

I want to solve the return quadratic issue the same way I did for 'visited'.