void (TreeItem<Data> child, TreeItem<Data> after) { child.setParent(this); int idx = -1; for (int i = 0; i < myChildren.size(); i++) { TreeItem<Data> item = myChildren.get(i); if (item.equals(after)) { idx = i; break; } } if (idx == -1) { myChildren.add(child); } else { myChildren.add(idx, child); } }