Object (Object parent, int index) { if (index == 0) { Object group = myGroup; if (group == null) { if (myRoot.equals(parent)) return myNode; } else { if (myRoot.equals(parent)) return group; if (group.equals(parent)) return myNode; } if (myNode.equals(parent)) return myLeaf; } throw new IllegalStateException(); }