public static void selectAllElementsLike(JList list, Object listElement,
            List<Integer> indexesOfDuplicates) {
        DefaultListModel model = (DefaultListModel) list.getModel();
        ListSelectionModel sm = list.getSelectionModel();
        int lastIndex = 0;
        for (Object element : model.toArray()) {
            if (element.equals(listElement)){
                int idx = model.indexOf(element, lastIndex);
                if (idx+1 < model.size()) {
                    lastIndex = idx+1; //possible Ex here
                }
                sm.addSelectionInterval(idx, idx);
                if (indexesOfDuplicates != null) {
                    indexesOfDuplicates.add(idx);
                }
            }
        }
    }