Or should it rather be:

isinstance(ufl_element.cell(), ufl.OuterProductCell):

?