del Operator in Arbitrarily Nested List
<p>I'm working with an instance of nltk.tree.ParentedTree, but I think the question is more general than that.</p>

<p>Basically, I have a list of arbitrarily deep nesting, and I want to delete part of the list (though I don't know how deeply nested that part is). I have a <code>search</code> function that finds an occurrence of an item in the list, which returns a tuple of <code>n</code> integers, where <code>n</code> is the depth of the element that was found.</p>

<p>For example, say I have <code>l = [[['cat', 'dog']], ['fish']]</code> When I call <code>search(l, 'dog')</code> it returns <code>(0, 0, 1)</code>. This is telling me that <code>l[0][0][1] == 'dog'</code>. If I knew that <code>'dog'</code> occurred at <code>(0, 0, 1)</code> ahead of time, I could delete it from the list just by doing <code>del l[0][0][1]</code>. But I don't know that ahead of time so I need to programmatically do the same kind of thing.</p>

<p>I can access the element <code>'dog'</code> in the list by doing</p>

<pre><code>indices = search(l, 'dog')
for i in indices:
    l = l[i]
</code></pre>

<p>So now <code>l</code> is <code>'dog'</code>. But, I'm not sure how to get from there to deleting it from the list. I don't just want to set it to <code>None</code>.</p>
