perhaps:

`if groupable?(input)`

where `groupable` is defined as:

```
def groupable?(element)
  element.respond_to?(:group_by)
end
```