This thread is a great illustration of the difference between the way you should do something, as opposed to what the code actually requires.
Code simply says pipe will be supported. It's silent on exactly how that will be done- and there's no listing requirement for the support means.
The thread also points out the need to know local rules. Since such pipe is likely to be tripped over, or moved about in roofing repair operations, it is fairly common for a local code to require the use of a ground wire for the circuits in the pipe, and not to rely only on the pipe for grounding. I have been told of places where their local codes also specified a distance above the roof.
What sort of flat roof? The grey rubber ones (EPDM) have their own rules. Most likely, a roofer will come out and glue down an additional thickness of the material under each of your sleepers.
I've not been happy with 2x4's - they seem to split too easily over time, and the added weight of a 4x4 seems to make for surer support. Whether to use pressure treated is your call, depending on your location. Make the sleepers at least a foot long, so as to spread the load over a fair amount of roof. On tar roofs, I glue them down with roofing mastic- and lots of it. Sure, it's messy ... you clean your tools with kerosene and WD-40.
You'll need to place them a lot closer than the code-required 10-ft spacing. I try to place them at least two to a stick of pipe, with one on either side of a bend.