@Nullable
  static PsiElement getSourcePsi(@NotNull PsiElement element) {
    if (element.isPhysical()) {
      return element;
    }
    // It is possible that some elements are non-physical (e.g. when we resolved kotlin reference in java file we get light element).
    // In such cases we want to get the original physical file from this non-physical element so that we can add annotation later on.
    // The simplest way to do it is to make two conversions: non-physical element -> uast element -> source psi
    UElement uElement = UastContextKt.toUElement(element);
    if (uElement == null) return null;
    PsiElement sourcePsi = uElement.getSourcePsi();
    if (sourcePsi == null) {
      SourceToSinkProvider provider = SourceToSinkProvider.sourceToSinkLanguageProvider.forLanguage(element.getLanguage());
      if (provider == null) return null;
      sourcePsi = provider.getPhysicalForLightElement(element);
    }
    return sourcePsi;
  }
@Nullable
  static PsiElement getSourcePsi(@NotNull PsiElement element)