void (@NotNull Stub root, @NotNull List<? super Stub> result) { ((ObjectStubBase<?>)root).id = result.size(); result.add(root); List<? extends Stub> childrenStubs = root.getChildrenStubs(); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < childrenStubs.size(); i++) { Stub child = childrenStubs.get(i); enumerateStubsInto(child, result); } }