I ended up creating a UBlueprintFunctionLibrary in C++ and use it from blueprint.
UTexture2D* UUtils::GetSpellIconByName(FString AssetName)
{
//todo: save the library a single time instead of doing for every spell
auto textureLibrary = UObjectLibrary::CreateLibrary(UTexture2D::StaticClass(), true, GIsEditor);
FString textPath = "/Game/SpellCasterComponent/Icons/SpellButtonIcons";
textureLibrary->LoadAssetDataFromPath(textPath);
TArray<FAssetData> Assets;
textureLibrary->GetAssetDataList(Assets);
for (auto& asset : Assets) {
if (asset.AssetName.ToString() == AssetName)
{
UTexture2D* found = Cast<UTexture2D>(asset.GetAsset());
if (found)
{
return found;
}
}
}
return nullptr;
}