use TreeIterator in the HasFunction