When my X5 ('05, 4.4i) started shifting wonky and going into limp mode, I went thru everything that could possibly cause the problem. In the end, I bit the bullet and replaced the transmission valve body with a rebuilt unit from RevMax. As you will see by studying this forum, X5's have a weak spot when it comes to the transmission mechatronics unit (what BMW calls the valve body). RevMax offers rebuilt units with upgraded solenoids that solve all the problems. While I don't want to tout RevMax, I just wanted you to know that they offer a solution that returned my X5 to like new shifting performance and I haven't seen limp mode since. I had it installed by my local indy BMW wrench and it was well under $2k
https://revmaxconverters.com/product...y-mechatronic/
AceEngineer