IProgramElement parent = typeElement.getParent();
// parent may have children: PACKAGE DECL, IMPORT-REFERENCE, TYPE_DECL
if (parent != null) {
// if it was the only type we should probably remove
// the others too.
parent.removeChild(typeElement);
if (parent.getKind().isSourceFile()) {
removeSourceFileIfNoMoreTypeDeclarationsInside(hierarchy, typeElement, parent);
} else {
hierarchy.forget(null, typeElement);
// At this point, the child has been removed. We