public static IProject getEnclosingProject(Object projectObj) {
		IProject project = null;

		if (projectObj instanceof List) {
			List<?> list = (List<?>) projectObj;
			if (list.size() == 1) {
				projectObj = list.iterator().next();
			}
		}

		if (projectObj instanceof FileEditorInput) {
			FileEditorInput fileEditorInput = (FileEditorInput) projectObj;
			project = fileEditorInput.getFile().getProject();
		}
		else if (projectObj instanceof IResource) {
			IResource resource = (IResource) projectObj;
			project = resource.getProject();
		}
		else if (projectObj instanceof IJavaElement) {
			IJavaElement javaElement = (IJavaElement) projectObj;
			IResource resource = javaElement.getResource();
			if (resource != null) {
				project = resource.getProject();
			}
		}

		return project;
	}
Tries to get the given project object's enclosing project.

@param projectObj The project object to get the enclosing project of.
@return The given project object's enclosing project.  Could be null if it could not be
  determined.
GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraProjectUtils.java