Object (@NotNull Object element, @NotNull String dataId) { if (CommonDataKeys.PSI_ELEMENT.is(dataId)) { if (element instanceof PsiElement) { return element; } if (element instanceof DataProvider) { return ((DataProvider)element).getData(dataId); } if (element instanceof PsiElementNavigationItem) { return ((PsiElementNavigationItem)element).getTargetElement(); } } return null; }