<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def disconnect(self, key=None, func=None):
 """Disconnect the connections to the an rcParams key Parameters key: str The rcParams key. If None, all keys are used func: function The function that is connected. If None, all functions are connected """

        if key is None:
            for key, connections in self._connections.items():
                for conn in connections[:]:
                    if func is None or conn is func:
                        connections.remove(conn)
        else:
            connections = self._connections[key]
            for conn in connections[:]:
                if func is None or conn is func:
                    connections.remove(conn)