void (boolean forward, @NotNull SyntaxElement leftParenthesis, @NotNull SyntaxElement rightParenthesis) { int parenLevel = 0; while (!myIterator.atEnd()) { SyntaxElement currElement = map(myIterator.getTokenType()); if (forward) { myIterator.advance(); } else { myIterator.retreat(); } if (rightParenthesis.equals(currElement)) { parenLevel++; } else if (leftParenthesis.equals(currElement)) { parenLevel--; if (parenLevel < 1) { break; } } } }