private function expand(Model $model, array $result, array $namedExc, array $namedInc, array $namedExp)
    {
        foreach ($namedExp as $k => $subExp) {
            $value = array_value($result, $k);
            if (!$this->isExpandable($model, $k, $value)) {
                continue;
            }

            $subExc = array_value($namedExc, $k);
            $subInc = array_value($namedInc, $k);

            // convert exclude, include, and expand into dot notation
            // then take the keys for a flattened dot notation
            $flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : [];
            $flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : [];
            $flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : [];

            $relation = $model->relation($k);
            $serializer = new self($this->request);
            $serializer->setExclude($flatExc)
                       ->setInclude($flatInc)
                       ->setExpand($flatExp);

            if ($relation instanceof Model) {
                $result[$k] = $serializer->toArray($relation);
            } else {
                $result[$k] = $relation;
            }
        }

        return $result;
    }