def pop()

in 1_synthetic-qa-generation/reasoningplaning/evolve.py [0:0]


    def pop(self) -> Tuple[Optional[Nde], Optional[str]]:
        """
        Pop the branch with the highest priority.

        Returns:
        - Tuple[Optional[Nde], Optional[str]]: The node and branch string, or (None, None) if empty.
        """
        while self.heap:
            neg_priority, unique_id = heapq.heappop(self.heap)
            # Check if this unique_id is still valid
            if unique_id in self.entry_finder:
                # Valid entry
                node, branch = self.id_to_branch.pop(unique_id)
                del self.entry_finder[unique_id]
                # Remove from latest_id_per_branch
                node_id = id(node)
                branch_key = (node_id, branch)
                if self.latest_id_per_branch.get(branch_key) == unique_id:
                    del self.latest_id_per_branch[branch_key]
                return node, branch
            # Else, outdated entry; skip
        return None, None