@Override
    public int checkTerminatingConditions() {
        int expiredTTLQueryCounter = 0;  // keeps count of how many queries
        // have had their TTL expire
        
        for (int iQuery = 0; iQuery < searchQueriesMap.size(); iQuery++) {
            final Query currentQuery = searchQueriesMap.get(iQuery);
            
            /* Checks if any of the current nodes belong to the set of target nodes. */
            final Iterator<Node> itCurrentNodes =
                    currentQuery.getCurrentNodesSet().iterator();
            Node aCurrentNode;
            
            while (itCurrentNodes.hasNext()) {
                aCurrentNode = itCurrentNodes.next();
                
                if (currentQuery.getTargetNodesSet().contains(aCurrentNode)) {
                    searchCoordinator.getControlPanel().getResultLabel()
                            .setText("SUCCESS! Found a target node.");
                    
                    searchResult = 1;
                    
                    return 1;
                }
            }
            
            /* Checks if TTL has been reached for each query. */
            if (ttlMap.get(iQuery) == 0) {
                expiredTTLQueryCounter++;
            }
        }
        
        /* Ends the search if the TTL for all the queries has expired. */
        if (expiredTTLQueryCounter == searchQueriesMap.size()) {
            searchCoordinator.getControlPanel().getResultLabel().setText(
                    "FAILURE. TTL expired.");
            
            return 1;
        }
        
        return 0;
        
    }