My 94 Maxima with 230,000 miles has had this problem on three seperate ocassions. I am not sure if each one was related as the problems arose several months or a couple years apart. This is how I fixed them, in order in which they occurred.
My mechanic recommended I replace the MAF sensor (about 1.5 years ago). Instead I took it out and cleaned it out with throttle body cleaner, very carefully and thoroughly. I read somewhere that electrical cleaner is recommend. Have not had to replace it since and I have passed two smog tests.
A year later I again took it to the mechanic and he replaced the ignition wires; I know I should have done this myself. You live and learn. Fixed the problem for the time being.
About four months ago the idle problem reared its ugly head again. I read the trouble codes it had to do with the injectors. Now three years ago a mechanic told me that my injectors may be going out soon so this did not surprise me. I took all the injectors out and sent them to Bill at http://www.mrinjector.us/
. He rebuilt them all and replaced two bad ones (free as he had two cores laying around) for under $100. The car runs great. I would strongly recommend this on any car with high miles. He will send you a printout of the injector flow before and after. My good injectors where not flowing to bad, however, they now flow like new.
What I discovered in the process was that my Maxima has more vacuum lines than any other car I have owned. I replaced many lines a few months back, but I discovered that I had missed good number of them hiding under the 3 piece intake and under other wires, etc. I have thrown in engine treatment and other engine cleaners. My gas mileage has been increasing and is currently around 26 mpg. Not bad as my driving habits vary greatly. Good luck.