<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_mirror_resources_by_name_map(self, scope=None):

 """ returns a map volume_name -> volume, cg_name->cg
 scope is either None or CG or Volume
 """

        volumes_mirrors_by_name = dict()
        cgs_mirrors_by_name = dict()
        if ((scope is None) or (scope.lower() == 'volume')):
            mirror_list = self.xcli_client.cmd.mirror_list(scope='Volume')
            for xcli_mirror in mirror_list:
                name = MirroredEntities.get_mirrored_object_name(xcli_mirror)
                volumes_mirrors_by_name[name] = xcli_mirror
        if ((scope is None) or (scope.lower() == CG)):
            for xcli_mirror in self.xcli_client.cmd.mirror_list(scope='CG'):
                name = MirroredEntities.get_mirrored_object_name(xcli_mirror)
                cgs_mirrors_by_name[name] = xcli_mirror
        res = Bunch(volumes=volumes_mirrors_by_name, cgs=cgs_mirrors_by_name)
        return res