check for group_by being defined before trying to make tree.
fix group_by