def _set_suffix_links(self):
self._suffix_links_set = True<EOL>for current, parent in self.bfs():<EOL><INDENT>if parent is None:<EOL><INDENT>continue<EOL><DEDENT>current.longest_prefix = parent.longest_prefix<EOL>if parent.has_value:<EOL><INDENT>current.longest_prefix = parent<EOL><DEDENT>if current.has_suffix:<EOL><INDENT>continue<EOL><DEDENT>suffix = parent<EOL>while True:<EOL><INDENT>if not suffix.has_suffix:<EOL><INDENT>current.suffix = self.root<EOL>break<EOL><DEDENT>else:<EOL><INDENT>suffix = suffix.suffix<EOL><DEDENT>if current.uplink in suffix:<EOL><INDENT>current.suffix = suffix[current.uplink]<EOL>break<EOL><DEDENT><DEDENT>suffix = current.suffix<EOL>while not suffix.has_value and suffix.has_suffix:<EOL><INDENT>suffix = suffix.suffix<EOL><DEDENT>if suffix.has_value:<EOL><INDENT>current.dict_suffix = suffix<EOL><DEDENT><DEDENT>
Sets all suffix links in all nodes in this trie.