KSC Open API  13.1
Kaspersky Security Center API description
array HostGroup::GetSubgroups ( int  nGroupId,
int  nDepth 
)

Receives a tree of subgroups in the administration group.

Parameters:
nGroupId(int) ID of the existing group.
nDepth(int) depth of the subgroup tree. 0 means all the grandchildren tree with no limits.
Returns:
(array) array of containers paramParams. Each of them contains up to three attributes: "id" (subgroup ID), "name" (subgroup name), and "groups" (similar recursive array). May be NULL.

See also how to use the KlAkOAPI Python package:

            def EnumerateGroups(oGroups, nLevel):
                for oGroup in oGroups:
                    nId = oGroup['id']
                    strName = oGroup['name']
                    # form indention for logging
                    strIndention = '    ' + '  ' * nLevel + '+-'
                    # log the found administration group
                    print(strIndention, 'Subgroup:', strName, ', id:', nId)
                    if 'groups' in oGroup:
                        groups = oGroup['groups']
                        EnumerateGroups(groups, nLevel + 1)
            def main():
                # server details            
                server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password", verify = False)
                oHostGroup = KlAkOAPI.HostGroup.KlAkHostGroup(server)
                # get ID of the root group ('Managed devices' group)
                nRootGroupID = oHostGroup.GroupIdGroups().RetVal()
                # enumerate subgroups of the root group
                oSubgroups = oHostGroup.GetSubgroups(nRootGroupID, 0).RetVal()
                EnumerateGroups(oSubgroups, 0)
            
See also:
Sample. Enumerating all groups.