@Nullable
  private static PsiElement bindAndCheckElement(@NotNull PsiReference ref,
                                                @NotNull PsiElement element,
                                                @NotNull PsiFileSystemItem item) {
    final PsiFileReference fileReference = ((FileReferenceOwner)ref).getLastFileReference();
    if (fileReference != null) {
      try {
        PsiElement newElement = fileReference.bindToElement(item);
        if (newElement != null) {
          // assertion for troubles like IDEA-59540
          LOG.assertTrue(element.getClass() == newElement.getClass(), "Reference " + ref + " violated contract of bindToElement()");
        }
        return newElement;
      }
      catch (IncorrectOperationException e) {
        LOG.error(e);
      }
    }

    return null;
  }
@Nullable
  private static PsiElement bindAndCheckElement(@NotNull PsiReference ref,
                                                @NotNull PsiElement element,
                                                @NotNull PsiFileSystemItem item)