### Question:
Optimizer { static Matcher removeSequentialMatchAny(Matcher matcher) { if (matcher instanceof ZeroOrMoreMatcher) { ZeroOrMoreMatcher zm1 = matcher.as(); if (zm1.repeated() instanceof AnyMatcher && zm1.next() instanceof ZeroOrMoreMatcher) { ZeroOrMoreMatcher zm2 = zm1.next().as(); if (zm2.repeated() instanceof AnyMatcher) { return zm2; } } } return matcher; } private  Optimizer();   }### Answer:
@Test public void removeSequentialMatchAny() { Matcher input = new ZeroOrMoreMatcher( AnyMatcher.INSTANCE, new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE) ); Matcher expected = new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, AnyMatcher.INSTANCE); Assertions.assertEquals(expected, Optimizer.removeSequentialMatchAny(input)); }