void (@NotNull StartMarker rootMarker, @NotNull CompositeElement rootNode) { ASTFactory astFactory = getASTFactory(); StartMarker curMarker = rootMarker; CompositeElement curNode = rootNode; int lexIndex = rootMarker.myLexemeIndex; ProductionMarker item = rootMarker.myFirstChild != null ? rootMarker.myFirstChild : rootMarker; boolean itemDone = rootMarker.myFirstChild == null; while (true) { lexIndex = insertLeaves(lexIndex, item.getLexemeIndex(itemDone), curNode); if (item == rootMarker && itemDone) break; if (item instanceof StartMarker) { StartMarker marker = (StartMarker)item; if (itemDone) { curMarker = (StartMarker)marker.myParent; curNode = curNode.getTreeParent(); item = marker.myNext; itemDone = false; } else if (!isCollapsed(marker)) { curMarker = marker; CompositeElement childNode = createComposite(marker, astFactory); curNode.rawAddChildrenWithoutNotifications(childNode); curNode = childNode; item = marker.myFirstChild != null ? marker.myFirstChild : marker; itemDone = marker.myFirstChild == null; continue; } else { lexIndex = collapseLeaves(curNode, marker); item = marker.myNext; } } else if (item instanceof ErrorItem) { CompositeElement errorElement = Factory.createErrorElement(((ErrorItem)item).myMessage); curNode.rawAddChildrenWithoutNotifications(errorElement); item = item.myNext; } if (item == null) { item = curMarker; itemDone = true; } } }