I don't have a reference at hand, but I recall reading somewhere that the tiredness attenuates some of the distractibility. Perhaps the mind is a bit less "agile"; it therefore foregos so readily jumping from topic to topic.
There is the counterpoint of hyperfocus. Something that is intensely interesting -- whether due to the topic itself or consuming pressure to get it done (NOW!) -- also lessens distractibility.
But if an all-nighter is truly the only option, then 20 minute naps every 2-3 hours works well combined with a cup of coffee.
Method: Drink a cup of coffee, immediately nap for 20 minutes, wake up and work for 2-3 hours. Rinse and repeat.