protected void remove(BaseComponent child, boolean noSync, boolean destroy) {
if (child instanceof IComposite) {
BaseComponent root = ((IComposite) child).getCompositeRoot();
BaseComponent parent = root == null ? null : root.getParent();
if (parent != null) {
parent.children.remove(root, noSync, destroy);
}
child.parent = null;
modCount++;
} else {
int index = indexOf(child);
ComponentException.assertTrue(index != -1, parent, "Child does not belong to this parent");
parent.beforeRemoveChild(child);
parent.nameIndex.remove(child);
child.parent = null;
delegate.remove(child);
modCount++;
if (!noSync) {
parent.invokeIfAttached("removeChild", child, destroy);
}
child.dead |= destroy;
parent.afterRemoveChild(child);
}
}