# Deleting / Exiting DataObjectTreeIterators

**URL:** https://discourse.vtk.org/t/deleting-exiting-dataobjecttreeiterators/6547
**Category:** Support
**Created:** [September 3, 2021, 4:19pm UTC](https://discourse.vtk.org/t/deleting-exiting-dataobjecttreeiterators/6547 "2021-09-03T16:19:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![csniker](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/c4cdca/32.png) [@csniker](https://discourse.vtk.org/u/csniker)
#### Post date: [September 3, 2021, 4:19pm UTC](https://discourse.vtk.org/t/deleting-exiting-dataobjecttreeiterators/6547/1 "2021-09-03T16:19:46Z")

</div>

I am using VTK in Python. I am using a DataObjectTreeIterator to traverse a MultiBlockDataSet by calling NewTreeIterator(). It appears to be working as expected, but I have two questions about improving performance:

**First Question:**  
The documentation here for NewTreeIterator() `https://vtk.org/doc/nightly/html/classvtkDataObjectTree.html#ae63004164efaca28b7ec2b87123f6c85` states that the iterator must be deleted by the user. I have seen no examples where this deletion is performed, nor do I see a method to do so. Do I need to add something to effect this deletion?

**Second Question:**  
I am using the iterator to look up data corresponding to a particular identifier. Once the identifier has been located, I can get the data, and I no longer need the iterator. Is there a way to break out of the iterator early (similar to using a “break” clause in a Python loop)? Assuming that there is, is breaking out of the iterator going to lead to any appreciable memory or time savings?
