'Recursively create a path of host groups.
Returns the id of the newly created hostgroup'

def create_group(self, fullpath):

    self.module.debug('Running    LogicMonitor.create_group...')
    res = self.get_group(fullpath)
    if res:
        self.module.debug(('Group    {0}    exists.' + fullpath))
        return res['id']
    if (fullpath == '/'):
        self.module.debug('Specified    group    is    root.    Doing    nothing.')
        return 1
    else:
        self.module.debug(('Creating    group    named    ' + fullpath))
        self.module.debug('System    changed')
        self.change = True
        if self.check_mode:
            self.exit(changed=True)
        (parentpath, name) = fullpath.rsplit('/', 1)
        parentgroup = self.get_group(parentpath)
        parentid = 1
        if (parentpath == ''):
            parentid = 1
        elif parentgroup:
            parentid = parentgroup['id']
        else:
            parentid = self.create_group(parentpath)
        h = None
        if hasattr(self, '_build_host_group_hash'):
            h = self._build_host_group_hash(fullpath, self.description, self.properties, self.alertenable)
            h['name'] = name
            h['parentId'] = parentid
        else:
            h = {'name': name, 'parentId': parentid, 'alertEnable': True, 'description': ''}
        self.module.debug("Making    RPC    call    to    'addHostGroup'")
        resp = json.loads(self.rpc('addHostGroup', h))
        if (resp['status'] == 200):
            self.module.debug('RPC    call    succeeded')
            return resp['data']['id']
        elif (resp['errmsg'] == 'The    record    already    exists'):
            self.module.debug('The    hostgroup    already    exists')
            group = self.get_group(fullpath)
            return group['id']
        else:
            self.module.debug('RPC    call    failed')
            self.fail(msg=((('Error:    unable    to    create    new    hostgroup    "' + name) + '".\n') + resp['errmsg']))
