ProjectIdentifier (@NotNull P project) { ProjectIdentifier projectIdentifier; if (project instanceof IdeaModule) { // do not use IdeaModule#getProjectIdentifier, it returns project identifier of the root project projectIdentifier = ((IdeaModule)project).getGradleProject().getProjectIdentifier(); } else { projectIdentifier = project.getProjectIdentifier(); } return projectIdentifier; }