<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def childgroup(self, field):
 """ Return a list of fields stored by row regarding the configured grid :param field: The original field this widget is attached to """

        grid = getattr(self, "grid", None)
        named_grid = getattr(self, "named_grid", None)

        if grid is not None:
            childgroup = self._childgroup(field.children, grid)
        elif named_grid is not None:
            childgroup = self._childgroup_by_name(field.children, named_grid)
        else:
            raise AttributeError(u"Missing the grid or named_grid argument")

        return childgroup