ReplaceRepeated (short form //.) uses a depth-first preorder traversal. As an alternative you might consider using a depth-first postorder traversal, as provided by MapAll (short form //@).
Because rm -rf's code goes in the top-down direction he used matching and prepending of multiple integers at once. Half way through the process the list is transformed into this:
{{1, 1}, {2, 2}, {{3, 3, 1}, {3, 3, 2}, {3, 31, {31, 1}, {32, 2}}}}
This may or may not have been your intention. For example, his method will expand {0, 1, {2, 2}, {3, 3}} into {{0, 1, 2, 2}, {0, 1, 3, 3}}. Suppose you didn't want this, and wanted to expand only list starting with a single atom rather than a sequence?
You might then use something like this:
f[{a_?AtomQ, b__List}] := Sequence @@ (Prepend[#, a] & /@ {b})
f[other_] := other
f //@ list
{{1, 1}, {2, 2}, {3, 3, 1}, {3, 3, 2}, {3, 31, 31, 1}, {3, 31, 32, 2}}
And:
list2 = {{1, 1}, {0, 1, {2, 2}}, {3, {3, 1}, {3, 2}, {31, {31, 1}, {32, 2}}}};
f //@ list2
{{1, 1}, {0, 1, {2, 2}}, {3, 3, 1}, {3, 3, 2}, {3, 31, 31, 1}, {3, 31, 32, 2}}
{{1,1},{2,2},{3,3,1},{3,3,2},{3,31,{31,1}},{3,31,{32,2}}}– Morry Aug 18 '13 at 19:42