def get_children(ns, obj, deep=False):
    obj = str2obj(ns, obj)
    if deep:
        # use loop of get_children(ns, xxx, deep=False)
        known_children = set()
        todo = [obj, ]  # a TO-DO list
        while todo:
            obj = todo.pop()
            new_children = get_children(ns, obj, False)
            for child in new_children:
                if "DeviceID" in child.properties():
                    devid = child.DeviceID
                else:
                    devid = child.InstanceID
                if devid not in known_children:
                    known_children.add(devid)
                    todo.append(child)
                    yield child
        return

    # only direct children requested
    if lmi_isinstance(obj, ns.CIM_StorageExtent):
        # try to find children VG first
        children = obj.associators(
                AssocClass="LMI_VGAssociatedComponentExtent",
                Role="PartComponent")
        if children:
            for child in children:
                yield child
            return

        # Extended partition don't have children
        extended = ns.LMI_DiskPartition.PartitionTypeValues.Extended
        if (lmi_isinstance(obj, ns.CIM_DiskPartition)
                    and obj.PartitionType == extended):
            return

        # try usual BasedOn next
        children = obj.associators(AssocClass="CIM_BasedOn", Role="Antecedent")
        for child in children:
            yield child
            # Be careful with logical partitions - they are BasedOn extended
            # partition, but we want to have them as children of appropriate
            # disk instead.
            if (lmi_isinstance(child, ns.CIM_DiskPartition)
                    and child.PartitionType == extended):
                LOG().debug("Looking for logical partitions on  %s"
                        % (child.DeviceID))
                for c in child.associators(AssocClass="CIM_BasedOn",
                        Role="Antecedent"):
                    yield c

    elif lmi_isinstance(obj, ns.CIM_StoragePool):
        # find thin pools from the VG
        assoc_class = "LMI_VGAllocatedFromStoragePool"
        if assoc_class in ns.classes():
            children = obj.associators(
                    AssocClass=assoc_class,
                    Role="Antecedent")
            for child in children:
                yield child

        # find LVs allocated from the VG
        children = obj.associators(
                AssocClass="LMI_LVAllocatedFromStoragePool",
                Role="Antecedent")
        for child in children:
            yield child
    else:
        raise LmiFailed("CIM_StorageExtent or LMI_VGStragePool expected: %s"
            % obj.classname)
Return list of all children of given LMIInstance.
dataset/ETHPy150Open openlmi/openlmi-scripts/commands/storage/lmi/scripts/storage/common.py/get_children