def _topological_sort_util(self, v: str, visited: set[str], order: list[str]):
        """Do depth-first search starting from node v.

        Iterative instead of recursive to avoid stack overflow for large graphs.
        """
        # keep track of the nodes to visit
        stack = [v]

        while stack:
            v = stack.pop()
            visited.add(v)

            for neighbor in self.get_consumers(v):
                if neighbor not in visited:
                    # remember to come back to this node
                    stack.append(v)
                    # visit the neighbor
                    stack.append(neighbor)
                    break
            else:
                order.insert(0, v)
Do depth-first search starting from node v.

        Iterative instead of recursive to avoid stack overflow for large graphs.
        
olive/passes/onnx/onnx_dag.py