def bfs(self, graph, start):
        """
        Performs BFS operation for eliminating useless loop transitions
        Args:
            graph (PDA): the PDA object
            start (PDA state): The PDA initial state
        Returns:
            list: A cleaned, smaller list of DFA states
        """
        newstatediag = {}

        # maintain a queue of paths
        queue = []
        visited = []
        # push the first path into the queue
        queue.append(start)
        while queue:
            # get the first path from the queue
            state = queue.pop(0)
            # get the last node from the path
            # visited
            visited.append(state.id)
            # enumerate all adjacent nodes, construct a new path and push it
            # into the queue
            for key in state.trans:
                if state.trans[key] != []:
                    if key not in visited:
                        for nextstate in graph:
                            if graph[nextstate].id == key:
                                queue.append(graph[nextstate])
                                break
        i = 0
        for state in graph:
            if graph[state].id in visited:
                newstatediag[i] = graph[state]
                i = i + 1

        return newstatediag
Performs BFS operation for eliminating useless loop transitions
        Args:
            graph (PDA): the PDA object
            start (PDA state): The PDA initial state
        Returns:
            list: A cleaned, smaller list of DFA states