public function groupBy(...$keys)
    {
        $data = [];

        while ($row = $this->getNextRow()) {

            $position = &$data;

            foreach ($keys as $key) {
                if (is_callable($key)) {
                    $value = $key($row);
                } else {
                    $value = $row[$key];
                }

                if (!array_key_exists($value, $position)) {
                    $position[$value] = [];
                }
                $position = &$position[$value];
            }

            $position[] = $row;
            unset($position);
        }

        return $data;
    }