def traverse_depth_first_pre_order(self, callback):
        """Visits the internal "nodes" of the enhanced suffix array in depth-first pre-order.

        Based on Abouelhoda et al. (2004).
        """
        n = len(self.suftab)
        root = [0, 0, n - 1, ""]  # <l, i, j, char>

        def _traverse_top_down(interval):  # TODO: Rewrite with stack? As in bottom-up
            callback(interval)
            i, j = interval[1], interval[2]
            if i != j:
                children = self._get_child_intervals(i, j)
                children.sort(key=lambda child: child[3])
                for child in children:
                    _traverse_top_down(child)

        _traverse_top_down(root)
def traverse_depth_first_pre_order ( self , callback ) : n = len ( self . suftab ) root = [ 0 , 0 , n - 1 , "" ] def _traverse_top_down ( interval ) : callback ( interval ) i , j = interval [ 1 ] , interval [ 2 ] if i != j : children = self . _get_child_intervals ( i , j ) children . sort ( key = lambda child : child [ 3 ] ) for child in children : _traverse_top_down ( child ) _traverse_top_down ( root )
Visits the internal "nodes" of the enhanced suffix array in depth-first pre-order.

        Based on Abouelhoda et al. (2004).