public function hierarchy($prefix = '', &$ignore = [], $index = false)
    {
        $hash = spl_object_hash($this);
        if (isset($ignore[$hash])) {
            return false;
        }
        $ignore[$hash] = true;

        $result = [];

        foreach ($this as $entity) {
            if ($hierarchy = $entity->hierarchy($prefix, $ignore, true)) {
                $result += $hierarchy;
            }
        }

        return $index ? $result : array_keys($result);
    }