<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def op_gate_of_type(op: raw_types.Operation, gate_type: Type[TV]) -> Optional[TV]: """Returns the gate of given type, if the op has that gate otherwise None. """

    if isinstance(op, GateOperation) and isinstance(op.gate, gate_type):
        return op.gate
    return None