public void traverseSelection(SelectionVisitor visitor) {

        // walk the section indices backwards
        List<Integer> sectionIndices = new ArrayList<>(selectionStateBySection.keySet());
        Collections.sort(sectionIndices, Collections.<Integer>reverseOrder());

        for (int sectionIndex : sectionIndices) {
            SectionSelectionState state = selectionStateBySection.get(sectionIndex);
            if (state == null) {
                continue;
            }

            if (state.section) {
                visitor.onVisitSelectedSection(sectionIndex);
            } else {

                if (state.footer) {
                    visitor.onVisitSelectedFooter(sectionIndex);
                }

                // walk items backwards
                for (int i = state.items.size() - 1; i >= 0; i--) {
                    if (state.items.valueAt(i)) {
                        visitor.onVisitSelectedSectionItem(sectionIndex, state.items.keyAt(i));
                    }
                }
            }
        }

    }
Walks the selection state of the adapter, in reverse order from end to front. This is to ensure that any additions or deletions
which are made based on selection are safe to perform.

@param visitor visitor which is invoked to process selection state
android/modules/module_common/src/main/java/github/tornaco/android/thanos/widget/section/SectioningAdapter.java