List<ConfigurationType> (List<ConfigurationType> fullList, String... ids) { List<String> idsList = Arrays.asList(ids); List<ConfigurationType> result = new ArrayList<>(); for (Iterator<ConfigurationType> iterator = fullList.iterator(); iterator.hasNext(); ) { ConfigurationType type = iterator.next(); if (idsList.contains(type.getId())) { result.add(type); //Note, here we remove an element from full 'plain' list as we put the element into some group iterator.remove(); } } return result; }