List<ProjectElement> elements = element.getElements(ProjectElement.class);
for( ProjectElement projectElement : elements ) {
doDelete(projectElement, deleteFiles, returncode);
}
Project projectInternal = element.getProjectInternal();
if (projectInternal != null)
projectInternal.getElementsInternal().remove(element);
else {
Project project = findProject(element);
if (project != null)
project.getElementsInternal().remove(element);
}
Resource resource = element.eResource();
if (resource != null) {
resource.getContents().remove(element);
resource.unload();