/** Removes this TreeNode from its parent. */ public void removeFromParent() { setParent(null); }
/** * Creates a TreeNode with the given parent, content, and initial child capacity. Automatically adds itself as a child of its parent. * <p> * {@code childCapacity} is provided strictly for performance reasons. */ @SuppressWarnings("unchecked") public TreeNode(@Nullable TreeNode<T> parent, T content, int childCapacity) { this.parent = parent; this.content = requireNonNull(content); setParent(parent); if (childCapacity == 0) { children = Collections.EMPTY_LIST; } else { children = new ArrayList<>(childCapacity); } }