I wanted to update this old thread because I was through this problem and didn't really find any conclusive explanations of a cure. I had a bad hesitation between 4000 and 5000 rpm. It would almost feel like in a weaker car when the air conditioning clutch kicks on. Car threw no codes or otherwise showed something was wrong. After around 5000 rpm it would take off again as if full power was restored.
Went to change the oil and realized it was way down on oil. During the change I came to do the filter and it was full of gummy, not new, oil spray on the outside. There was zero indication of this having happened under the car in the driveway, no dash light, etc. As it turns out the 500S filter had a failing oring seal. I suspect it was only blowing oil past the seal at high rpm when the pressures increased, but nonetheless the oil level was now embarrassingly low. Changing the filter and putting in the standard 8qts of new oil, the hesitation problem immediately ceased. I hadn't realized it during driving before the oil change, but afterwards I could tell the car was actually down on power almost across the whole rpm band, not just the hesitation previously described. I am unsure if the loss in power was related to the low oil level, or the fact that the seal was blowing and leaking purging oil pressure only at high rpm. Post-oil change though with the new filter, everything is back to normal.
So if you're having this hesitation problem, try changing the oil/filter. Certainly beats paying a diag fee if this ends up being your problem.