public static @Nullable PsiElement findCommonContext(@NotNull Collection<? extends @Nullable PsiElement> elements) {
    if (elements.isEmpty()) return null;
    PsiElement toReturn = null;
    for (PsiElement element : elements) {
      if (element == null) continue;
      toReturn = toReturn == null ? element : findCommonContext(toReturn, element);
      if (toReturn == null) return null;
    }
    return toReturn;
  }
public static @Nullable PsiElement findCommonContext(@NotNull Collection<? extends @Nullable PsiElement> elements)