Found this super helpful so thought I should add my experience.
bought an 08 FG xr6 turbo and it was running perfectly fine until I bought a new battery for it.
Immediately it began hunting once warm, getting down around 250rpm and then recovering. Sometimes stalling.
literally every stop sign It would stall if I didn’t put it in neutral quick enough.
swapped the old battery back in and the issue remained.
no fault codes coming up.
found this thread and added the extra earth cables one at a time. It was the earth strap from the intake manifold to the chassis (air box bolt) that made all the difference.
immediatly, the engine wasn’t stalling anymore. The hunting however had reduced to almost non existent.
I then cleaned the throttle body with a good throttle body cleaner and put in new plugs and its completely fixed.
hope this helps someone like it helped me!