protected @Nullable PsiElement checkLocalScope(PsiElement element) {
    final SearchScope searchScope = PsiSearchHelper.getInstance(element.getProject()).getUseScope(element);
    if (searchScope instanceof LocalSearchScope) {
      final PsiElement[] elements = ((LocalSearchScope)searchScope).getScope();
      return PsiTreeUtil.findCommonParent(elements);
    }

    return null;
  }
protected @Nullable PsiElement checkLocalScope(PsiElement element)