Repository: Qiskit/qiskit

Issue:
Pulse compression increases recursion depth of the schedule
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: master
- **Python version**: 3.7
- **Operating system**: 

### What is the current behavior?

The pulse compress may increase the recursion depth of input schedule and crash the pulse assembler.

### Steps to reproduce the problem

Prepare very long schedule
```python
from qiskit.ignis.verification import randomized_benchmarking_seq
import numpy as np
from qiskit.test.mock import FakeAlmaden
from qiskit.pulse import transforms

rb_circs, xdata = randomized_benchmarking_seq(length_vector=[350], nseeds=1, rb_pattern=[[0]])
transpiled_rb_circs = qiskit.transpile(rb_circs[0], backend=FakeAlmaden(), optimization_level=0)
rb_scheds = qiskit.schedule(transpiled_rb_circs, backend=FakeAlmaden())

rb_scheds.instructions

transformed_sched = transforms.compress_pulses([rb_scheds])
transformed_sched[0].instructions # this causes an error
```

```
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-99-d345b17804b7> in <module>
     11 
     12 transformed_sched = transforms.compress_pulses([rb_scheds])
---> 13 transformed_sched[0].instructions

~/qiskit/qiskit-terra/qiskit/pulse/schedule.py in instructions(self)
    126                     sorted(chan.name for chan in inst.channels))
    127 
--> 128         return tuple(sorted(self._instructions(), key=key))
    129 
    130     def ch_duration(self, *channels: List[Channel]) -> int:

~/qiskit/qiskit-terra/qiskit/pulse/schedule.py in _instructions(self, time)
    174         """
    175         for insert_time, child_sched in self._children:
--> 176             yield from child_sched._instructions(time + insert_time)
    177 
    178     def union(self,

... last 1 frames repeated, from the frame below ...

~/qiskit/qiskit-terra/qiskit/pulse/schedule.py in _instructions(self, time)
    174         """
    175         for insert_time, child_sched in self._children:
--> 176             yield from child_sched._instructions(time + insert_time)
    177 
    178     def union(self,

RecursionError: maximum recursion depth exceeded while calling a Python object
```

Note that `rb_scheds.instructions` does work.
If we use two qubits for RB, the assembler crashes at almost the half clifford length ~ 150.
This is a realistic setup and should be supported.
Perhaps QV is also affected.

### What is the expected behavior?

Transform module should convert the schedule so that transformed schedule has the almost constant recursion depth.

### Suggested solutions

I'm not familiar with the logic of transform. @taalexander 



Discussion:
Instead of using `<<` and `|=` please trying using `sched. insert(inst, inplace=True)`

Resolving patch:
diff --git a/qiskit/pulse/transforms.py b/qiskit/pulse/transforms.py
--- a/qiskit/pulse/transforms.py
+++ b/qiskit/pulse/transforms.py
@@ -110,13 +110,13 @@ def get_max_calibration_duration():
                 if time > align_time:
                     warnings.warn("You provided an align_time which is scheduling an acquire "
                                   "sooner than it was scheduled for in the original Schedule.")
-                new_schedule |= inst << align_time
+                new_schedule.insert(align_time, inst, inplace=True)
                 acquired_channels.add(inst.channel.index)
             elif isinstance(inst.channels[0], chans.MeasureChannel):
-                new_schedule |= inst << align_time
+                new_schedule.insert(align_time, inst, inplace=True)
                 measured_channels.update({a.index for a in inst.channels})
             else:
-                new_schedule |= inst << time
+                new_schedule.insert(time, inst, inplace=True)
 
         new_schedules.append(new_schedule)
 
@@ -168,7 +168,7 @@ def add_implicit_acquires(schedule: interfaces.ScheduleComponent,
                     new_schedule |= explicit_inst
                     acquire_map[time].add(i)
         else:
-            new_schedule |= inst << time
+            new_schedule.insert(time, inst, inplace=True)
 
     return new_schedule
 
@@ -246,9 +246,9 @@ def compress_pulses(schedules: List[Schedule]) -> List[Schedule]:
                         identical_pulse, inst.channel, inst.name) << time
                 else:
                     existing_pulses.append(inst.pulse)
-                    new_schedule |= inst << time
+                    new_schedule.insert(time, inst, inplace=True)
             else:
-                new_schedule |= inst << time
+                new_schedule.insert(time, inst, inplace=True)
 
         new_schedules.append(new_schedule)
 


Test patch: