(</span><span class="s2">&quot;The input tree is not a valid tree.&quot;</span><span class="p">)</span>

        <span class="c1"># No matter what, add a dummy node, point the old root at it and </span>
        <span class="c1"># eventually give that new node function value infinity. </span>
        <span class="n">T</span><span class="o">.</span><span class="n">add_node</span><span class="p">(</span><span class="s1">&#39;v_inf&#39;</span><span class="p">)</span>
        <span class="n">T</span><span class=