N (N parent, String frame) { for (N child : parent.children) { if (child.whatever.equals(frame)) { return child; } } N result = new N(parent, new ArrayList<>(), frame); parent.children.add(result); return result; }