private void traversePatternTree(List<PatternInfo> patternInfos, List<RuleConditionElement> ruleElements, List<BaseDescr> lhsDescrs) {
if (ruleElements.size() != lhsDescrs.size()) {
throw new RuntimeException("Cannot traverse pattern tree");
}
for (int i = 0; i < ruleElements.size(); i++) {
RuleConditionElement ruleElement = ruleElements.get(i);
BaseDescr lhsDescr = lhsDescrs.get(i);
if (ruleElement instanceof Pattern && lhsDescr instanceof PatternDescr) {
patternInfos.add(new PatternInfo((PatternDescr)lhsDescr, (Pattern)ruleElement));
endPatternsCharacter = Math.max(endPatternsCharacter, ((PatternDescr)lhsDescr).getEndCharacter());