The recursion is necessary. Since nuget.config can exists in any directory of the path. Maybe the loop can be removed, I don't know how to do it, exists any First in Powershell?