How to get all materials from path?

How do I get all materials (/Game/Materials) from the path in C++? Currently, I have code that gets all material INSTANCES in game (to be used in a drop down menu), but to get that code to work, I have to manually go into UE, and create an instance for each material. How do I get the original materials (not the instances)?How would I be able to adapt this to get UMaterials instead of UMaterialInstances? (This is my function for instances:)

TArray<UMaterialInstance*> UNewBlueprintFunctionLibrary::getMaterialInstancesFromPath(FString _path) {
     TArray<UMaterial*> result =  TArray<UMaterialInstance*>();
     UObjectLibrary *lib = UObjectLibrary::CreateLibrary(UMaterialInstance::StaticClass(), false, true);
     UE_LOG(LogTemp, Warning, TEXT("Searching for material instances in /Game/Materials..."));
     TArray<FAssetData> assetData;
     UE_LOG(LogTemp, Warning, TEXT("Found %d"), assetData.Num());
     for (FAssetData asset : assetData) {
         UMaterialInstance* mi = Cast<UMaterialInstance>(asset.GetAsset());
         if (mi) {
             UE_LOG(LogTemp, Warning, TEXT("Material instance %s"), *mi->GetName());
     return result;