protected function getPermissionGroupIndex($groups)
    {
        $index = [];

        foreach ($groups as $key => $presence) {

            $permissions = $presence->permissions();

            if ( ! $permissions) {
                continue;
            }

            if ( ! is_array($permissions)) {
                $permissions = [ $permissions ];
            }

            foreach ($permissions as $permission) {
                $index[ $permission ] = $key;
            }
        }

        return $index;
    }