public static Optional<Integer> getPreviousSequence(final List<Integer> sequences, final int currentSequence) {
        if (sequences.size() <= 1) {
            return Optional.empty();
        }
        sequences.sort(Integer::compareTo);
        Integer index = null;
        for (int i = 0; i < sequences.size(); i++) {
            if (sequences.get(i) == currentSequence) {
                index = i;
                break;
            }
        }
        if (null == index) {
            return Optional.empty();
        }
        return Optional.of(index >= 1 ? sequences.get(index - 1) : MAX_SEQUENCE);
    }
@Test
    void assertGetPreviousSequence() {
        List<Integer> sequences = Arrays.asList(2, 3, 1);
        Optional<Integer> previousSequence = ConsistencyCheckSequence.getPreviousSequence(sequences, 3);
        assertTrue(previousSequence.isPresent());
        assertThat(previousSequence.get(), is(2));
        previousSequence = ConsistencyCheckSequence.getPreviousSequence(sequences, 2);
        assertTrue(previousSequence.isPresent());
        assertThat(previousSequence.get(), is(1));
        previousSequence = ConsistencyCheckSequence.getPreviousSequence(sequences, 1);
        assertTrue(previousSequence.isPresent());
        assertThat(previousSequence.get(), is(3));
        previousSequence = ConsistencyCheckSequence.getPreviousSequence(sequences, 4);
        assertFalse(previousSequence.isPresent());
    }