<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def to_spans(self):
        "Convert the tree to a set of nonterms and spans."
        s = set()
        self._convert_to_spans(self.tree, 1, s)
        return s