protected function getChildren($collection, $id)
    {
        $parentField = $this->repository->getParentField();
        $result = [];
        foreach ($collection as $instance) {
            if ((int) $instance->$parentField != $id) {
                continue;
            }

            $instance->setRelation(
                'children',
                $this->getChildren($collection, $instance->getKey())
            );

            $result[] = $instance;
        }

        return new Collection($result);
    }