protected function prepareRestRequest(array &$parts)
    {
        if (!empty($parts) && in_array($parts[0], $this->restPrefixes)) {
            /*
             * if the request is something like /_/posts/1/comments/2
             * it will convert it to something like /posts/comments/1/2
             */

            // first remove the REST prefix
            array_shift($parts);

            $restRoute = $restParams = [];
            $i = 1;

            foreach ($parts as $part) {
                if ($i % 2) {
                    $restRoute[] = $part;
                } else {
                    $restParams[] = $part;
                }

                $i++;
            }

            $parts = array_merge($restRoute, $restParams);
        }
    }