>def</span> <span class="nf">union_treap</span><span class="p">(</span><span class="n">T1</span><span
        class="p">,</span> <span class="n">T2</span><span class="p">):</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">T2</span> <span class="ow">or</span> <span
            class="ow">not</span> <span class="n">T2</span><span class="o">.</span><span class="n">root</span><span
            class="p">:</span>
        <span class="k">return</span> <span class="n">T1</span>
    