private function getExpandedRoles(array $roleScopes)
    {
        $expandedRoles = array();
        foreach ($roleScopes as $roleScope) {
            if (!array_key_exists($roleScope->getRole(), $expandedRoles)) {
                $expandedRoles[$roleScope->getRole()] = 
                      array_map(
                            function(RoleInterface $role) {
                          
                                return $role->getRole();
                            },
                            $this->get('security.role_hierarchy')
                                ->getReachableRoles(
                                      array(new Role($roleScope->getRole()))
                                    )
                        );
            }
        }
        return $expandedRoles;
    }