IndexedLighterASTNode (@NotNull IndexedLighterASTNode element) { List<LighterASTNode> children = ast.getChildren(element.node); IndexedLighterASTNode[] indexedChildren = children.isEmpty() ? IndexedLighterASTNode.EMPTY_ARRAY : new IndexedLighterASTNode[children.size()]; for (int i = 0; i < children.size(); i++) { LighterASTNode child = children.get(i); IndexedLighterASTNode indexedNode = new IndexedLighterASTNode(child, i == 0 ? null : indexedChildren[i - 1]); indexedChildren[i] = indexedNode; if (i != 0) { indexedChildren[i-1].next = indexedNode; } } parentStack.push(element); return children.isEmpty() ? null : indexedChildren[0]; }