Object (DataContext dataContext) { // Narrow down the root element to the first interesting one Module root = PlatformCoreDataKeys.MODULE.getData(dataContext); if (root != null && !ModuleType.isInternal(root)) return root; Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return null; Object projectChild; Object projectGrandChild = null; CommonProcessors.FindFirstAndOnlyProcessor<Object> processor = new CommonProcessors.FindFirstAndOnlyProcessor<>(); processChildren(project, processor); projectChild = processor.reset(); if (projectChild != null) { processChildren(projectChild, processor); projectGrandChild = processor.reset(); } return ObjectUtils.chooseNotNull(projectGrandChild, ObjectUtils.chooseNotNull(projectChild, project)); }