code: def op_gate_of_type(op: raw_types.Operation,
                      gate_type: Type[TV]) -> Optional[TV]:
      
      if isinstance(op, GateOperation) and isinstance(op.gate, gate_type):
          return op.gate
      return None
docs: Returns the gate of given type, if the op has that gate otherwise None.