'Return the next element in the stream.  If out of elements, throw
an exception unless size()==1.  If size is 1, then return elements[0].
Return a duplicate node/subtree if stream is out of elements and
size==1. If we\'ve already used the element, dup (dirty bit set).'

def nextTree(self):

    if (self.dirty or ((self.cursor >= len(self)) and (len(self) == 1))):
        el = self._next()
        return self.dup(el)
    el = self._next()
    return el
