XmlElementDescriptor (XmlTag childTag) { final List<DElementPattern> patterns = new ArrayList<>(); for (DElementPattern pattern : myPatterns) { patterns.addAll(ChildElementFinder.find(2, pattern)); } // TODO: filter out impossible variants: /* while this needs both variants of <choice>-children <element><choice><caret> this does not, because <choice> inside <choice> is unambiguous: <element><choice><data type="string" /><choice><caret> */ final XmlElementDescriptor d = myNsDescriptor.findDescriptor(childTag, patterns); if (d != null) { return d; } return NULL; }