<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_spawned_gates(self, spawn_gate=None):
 """ Removes all spawned gates. """

        if spawn_gate is None:
            for sg in list(self.spawn_list):
                self.spawn_list.remove(sg)
                sg.remove()
        else:
            spawn_gate.remove()
            self.spawn_list.remove(spawn_gate)