Again to solve 'Too deep instantiation', but this time using tail recursion optimization on conditions.