A Few Suggestions:
(1) If you have a VERY Dirty Air Filter and a likewise, contaminated MAF sensor that needs a Good Cleaning with CRC MAF Solvent... this area is THE "LHF" Place to Start (Low Hanging Fruit) looking for issues with Sketchy A/F activity:
Screen Capture via a YT Video:
(2) Get a Can of Starter Fluid and with a Fire Extinguisher at hand, Spray along the Intake Manifold Flange at the Head Intake Ports while the Engine is Idling and see if the RPM elevates. Do
--NOT-- Over-Spray with the Starter Fluid!
Do --NOT-- Do this Test inside of an enclosed -closed Garage
(3) If the RPM goes up suddenly... Visit all of the "Trapped Fasteners" holding the Intake Manifold to the Head... and Tighten them all back down to 89 Inch Pounds...
and NO MORE. The Fasteners are MEANT to Bottom Out on a Bolt Ledge that WILL Snap Off if too much Torque is applied. It may come down to cases that replacing the *Flattened* Rubber "O" Ring Style Gasket Set to put things right.
(4) THIS is not a Trivial Job since gaining access to the staggered 10mm IM Fasteners to R&R the IM requires jacking up the SUV, Using a Jack Stand to support the Vehicle and removing the Left Front Wheel in order to access the lower IM Bolts through the Wheel Well and work on the one near the Firewall with a combination of Ratchet, U-Joint and Socket to get at to them. There are other like-minded Threads with more ideas on how to do this part properly.
(5) If the Upstream 02 Sensor is failing, or if there are MAJOR Air Leaks along the Exhaust Manifold from having Broken EM Bolts... then Random Ingested, Unregulated Air can skew the A/F responses via the O2s actually doing their jobs correctly.
(6) A Leaking SAIS Gasket or Stuck SAIS Solenoid (Passenger Side of the Engine Head) can also cause weird P0171 issues by allowing unregulated AIR to get access to the Q2 Sensors in the exhaust gas air stream.