IntList (@NotNull String s) { IntList indices = new IntArrayList(); String trimmed = s.trim(); ListIterator<Object> iterator = getElementIterator(0); while (iterator.hasNext()) { Object element = iterator.next(); if (isMatchingElement(element, trimmed)) { indices.add(iterator.previousIndex()); } } return indices; }