protected function _index($collection, $name)
    {
        $indexes = [];
        foreach ($collection as $key => $entity) {
            if (is_object($entity)) {
                if ($entity->{$name}) {
                    $indexes[(string) $entity->{$name}] = $key;
                }
            } else {
                if (isset($entity[$name])) {
                    $indexes[(string) $entity[$name]] = $key;
                }
            }
        }
        return $indexes;
    }