public Selector buildSelector() {
Iterator<HiddenTokenAwareTree> iterator = token.getChildren().iterator();
Selector result = new Selector(token, new ArrayList<SelectorPart>());
while (iterator.hasNext()) {
SelectorCombinator combinator = null;
SelectorPart part = null;
HiddenTokenAwareTree kid = iterator.next();
if (ConversionUtils.isSelectorCombinator(kid)) {
combinator = ConversionUtils.createSelectorCombinator(kid);
kid = iterator.next();
part = (SelectorPart) parent.switchOn(kid);
// Ignore descendant combinator before appender. This info is already hidden in appender.isDirectlyBefore.
if (isDescendant(combinator) && kid.getType() == LessLexer.NESTED_APPENDER)
combinator = null;
} else {
//if it is not a combinator, then it is either nested appender, simple selector or escaped selector
part = (SelectorPart) parent.switchOn(kid);
}
part.setLeadingCombinator(combinator);
if (combinator != null)
part.getUnderlyingStructure().moveHidden(combinator.getUnderlyingStructure(), null);
addPart(result, part);
}
return result;
}