public function treeify($embed)
    {
        if (!$embed) {
            return [];
        }
        $embed = Set::expand(Set::normalize((array) $embed), ['affix' => 'embed']);

        $result = [];
        foreach ($embed as $relName => $value) {
            if (!isset($this->_relations[$relName])) {
                continue;
            }
            if ($this->_relations[$relName]['relation'] === 'hasManyThrough') {
                $rel = $this->relation($relName);
                if (!isset($result[$rel->through()]['embed'][$rel->using()])) {
                    $result[$rel->through()]['embed'][$rel->using()] = $value;
                }
            }
            $result[$relName] = $value;
        }
        return $result;
    }