public function getIncludedRoles( core_kernel_classes_Resource $role)
    {
        $returnValue = array();

    	if (GENERIS_CACHE_USERS_ROLES === true && core_kernel_users_Cache::areIncludedRolesInCache($role) === true){
            $returnValue = core_kernel_users_Cache::retrieveIncludedRoles($role);
        }
        else{
	        // We use a Depth First Search approach to flatten the Roles Graph.
	        $includesRoleProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_ROLE_INCLUDESROLE);
	        $visitedRoles = array();
	        $s = array(); // vertex stack.
	        array_push($s, $role); // begin with $role as the first vertex.
	        
	        while (!empty($s)){
	        	$u = array_pop($s);
	
	        	if (false === in_array($u->getUri(), $visitedRoles, true)){
	        		$visitedRoles[] = $u->getUri();
	        		$returnValue[$u->getUri()] = $u;
	        		
	        		$ar = $u->getPropertyValuesCollection($includesRoleProperty);
	        		foreach ($ar->getIterator() as $w){
	        			if (false === in_array($w->getUri(), $visitedRoles, true)){ // not visited
	        				array_push($s, $w);
	        			}
	        		}
	        	}
	        }
	        
	        // remove the root vertex which is actually the role we are testing.
	        unset($returnValue[$role->getUri()]);
	        
	        if (GENERIS_CACHE_USERS_ROLES === true){
	        	try{
					core_kernel_users_Cache::cacheIncludedRoles($role, $returnValue);
	        	}
	        	catch(core_kernel_users_CacheException $e){
	        		$roleUri = $role->getUri();
	        		$msg = "Unable to retrieve included roles from cache memory for role '${roleUri}': ";
	        		$msg.= $e->getMessage();
	        		throw new core_kernel_users_Exception($msg);	
	        	}
	        }
        }

        return (array) $returnValue;
    }