protected static function restGetFieldsDepth($default = 1)
    {
        $depth = Request::getInstance()->query('_fieldsDepth', false);
        if (!$depth) {
            $fields = static::restGetFields(false);
            if (!$fields) {
                return $default;
            }

            // Determine the deepest key
            $depth = 1;
            foreach (explode(',', $fields) as $key) {
                $keyDepth = substr_count($key, '.');
                if ($depth < $keyDepth) {
                    $depth = $keyDepth;
                }
            }
            return $depth;
        }

        return $depth;

    }