public static PsiReference[] filterByOffset(PsiReference[] references, int offset) {
    return StreamEx.of(references)
      .flatMap(ref ->
                 ref instanceof PsiDynaReference<?>
                 ? StreamEx.of(((PsiDynaReference<?>)ref).myReferences).filter(it -> it.getRangeInElement().contains(offset))
                 : StreamEx.of(ref)
      ).toArray(PsiReference.EMPTY_ARRAY);
  }
public static PsiReference[] filterByOffset(PsiReference[] references, int offset)