Update ext.group_by.php

Looks like a handy extension. Just made some changes so the function returns as early as possible if there is nothing else to do. Reduces nesting and makes it easier to read.