Yes, please use isinstance. Otherwise, it's impossible to use a custom subclass of `Sum` with your code.