protected static Map<DeltaSQLStatementSnapshot, List<WaitEventForStatementTuple>> loadWaitEventsForStatements(
            List<DeltaSQLStatementSnapshot> worstStatements,
            Calendar startTime,
            Calendar stopTime,
            ProgressListener progressListener) {

        Map<DeltaSQLStatementSnapshot, List<WaitEventForStatementTuple>> result = new HashMap<>();

        if (progressListener != null) {
            progressListener.setStartValue(0);
            progressListener.setEndValue(worstStatements.size());
            progressListener.setCurrentValue(0);
        }

        int progressCounter = 0;

        List<DeltaSQLStatementSnapshot> missingWaitEventSqlStatements = new ArrayList<>(worstStatements);
        List<DeltaSQLStatementSnapshot> sqlStatementsToLoad = new ArrayList<>();

        int numberStatements;

        while (missingWaitEventSqlStatements.size() > 0) {
            sqlStatementsToLoad.clear();
            numberStatements = 0;

            Iterator<DeltaSQLStatementSnapshot> iterator = missingWaitEventSqlStatements.iterator();

            while (iterator.hasNext() && numberStatements <= NUMBER_BIND_VARIABLES_SELECT_WAIT_EVENTS_SQL) {
                sqlStatementsToLoad.add(iterator.next());
                numberStatements++;
            }

            // remove those statements from the initial for which the loading is
            // going on
            for (DeltaSQLStatementSnapshot statement : sqlStatementsToLoad) {
                missingWaitEventSqlStatements.remove(statement);
            }

            loadWaitEventsForSQLStatements(sqlStatementsToLoad, startTime, stopTime, result);

            progressCounter += sqlStatementsToLoad.size();

            if (progressListener != null) {
                progressListener.setCurrentValue(progressCounter);
            }

            // sleep for 0.1 seconds so all the other tasks can do their
            // work
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // we don't care for being interrupted
            }
        }

        if (progressListener != null) {
            progressListener.informFinished();
        }

        return result;
    }