public static function groupByType(array $objects)
    {
        $perType = [];
        foreach ($objects as $object) {
            $type = $object->getType();
            if (!isset($perType[$type])) {
                $perType[$type] = [];
            }
            $perType[$type][] = $object;
        }
        return $perType;
    }