def parse(self, document, text):
stack = []<EOL>root = lxml.html.fromstring(text)<EOL>if self.flatten:<EOL><INDENT>lxml.etree.strip_tags(root, self.flatten)<EOL><DEDENT>document.text = lxml.etree.tostring(root, encoding="<STR_LIT>")<EOL>state = {<EOL>"<STR_LIT>": set(),<EOL>"<STR_LIT>": {},  <EOL>"<STR_LIT>": {},  <EOL>"<STR_LIT:root>": root,<EOL>"<STR_LIT>": document,<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>},<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>},<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>},<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>},<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>},<EOL>"<STR_LIT>": {"<STR_LIT>": <NUM_LIT:0>, "<STR_LIT>": <NUM_LIT:0>},<EOL>}<EOL>stack.append(root)<EOL>state["<STR_LIT>"][root] = document<EOL>state["<STR_LIT>"][root] = document<EOL>tokenized_sentences = []<EOL>while stack:<EOL><INDENT>node = stack.pop()<EOL>if node not in state["<STR_LIT>"]:<EOL><INDENT>state["<STR_LIT>"].add(node)  <EOL>if self.lingual:<EOL><INDENT>tokenized_sentences += [y for y in self._parse_node(node, state)]<EOL><DEDENT>else:<EOL><INDENT>yield from self._parse_node(node, state)<EOL><DEDENT>for child in reversed(node):<EOL><INDENT>if child.tag is lxml.etree.Comment or (<EOL>self.blacklist and child.tag in self.blacklist<EOL>):<EOL><INDENT>continue<EOL><DEDENT>stack.append(child)<EOL>state["<STR_LIT>"][child] = (<EOL>state["<STR_LIT>"][node]<EOL>if node in state["<STR_LIT>"]<EOL>else state["<STR_LIT>"][node]<EOL>)<EOL><DEDENT><DEDENT><DEDENT>if self.lingual:<EOL><INDENT>yield from self.enrich_tokenized_sentences_with_nlp(tokenized_sentences)<EOL><DEDENT>
Depth-first search over the provided tree.

        Implemented as an iterative procedure. The structure of the state
        needed to parse each node is also defined in this function.

        :param document: the Document context
        :param text: the structured text of the document (e.g. HTML)
        :rtype: a *generator* of Sentences.