kiberkun,
$(function() {
var trs = $($("tr").get().reverse()), accumulator;
trs.each(function(i, tr){
if($("tr").length == 9) return;
if($("td > div", accumulator).length == 4||!accumulator) accumulator = tr;
else {$("td", accumulator).prepend($("div", tr)); $(tr).remove()}
})
});