private static @Nullable PsiElement findDeclaringElement(@NotNull PsiElement potentiallyIdentifyingElement) {
    PsiElement parent = potentiallyIdentifyingElement.getParent();
    if (parent instanceof PsiNameIdentifierOwner &&
        ((PsiNameIdentifierOwner)parent).getIdentifyingElement() == potentiallyIdentifyingElement) {
      return parent;
    }
    for (JvmDeclarationSearcher searcher : JvmDeclarationSearcher.EP.allForLanguage(potentiallyIdentifyingElement.getLanguage())) {
      PsiElement declaringElement = searcher.adjustIdentifierElement(potentiallyIdentifyingElement);
      if (declaringElement != null) {
        return declaringElement;
      }
    }
    return null;
  }
private static @Nullable PsiElement findDeclaringElement(@NotNull PsiElement potentiallyIdentifyingElement)