eliminated `is_Tensor`; factored two helper functions out of `_contract`