def flatten(self, type=None):
    'Return members, converting nested object sets into its members\n\n        Example:\n            >>> from maya import cmds\n            >>> _ = cmds.file(new=True, force=True)\n            >>> a = cmds.createNode("transform", name="a")\n            >>> b = cmds.createNode("transform", name="b")\n            >>> c = cmds.createNode("transform", name="c")\n            >>> cmds.select(a)\n            >>> gc = cmds.sets([a], name="grandchild")\n            >>> cc = cmds.sets([gc, b], name="child")\n            >>> parent = cmds.sets([cc, c], name="parent")\n            >>> mainset = encode(parent)\n            >>> sorted(mainset.flatten(), key=lambda n: n.name())\n            [|a, |b, |c]\n\n        '
    members = set()

    def recurse(objset):
        for member in objset:
            if member.isA(om.MFn.kSet):
                recurse(member)
            elif (type is not None):
                if (type == member.typeName):
                    members.add(member)
            else:
                members.add(member)
    recurse(self)
    return list(members)
Return members, converting nested object sets into its members

Example:
    >>> from maya import cmds
    >>> _ = cmds.file(new=True, force=True)
    >>> a = cmds.createNode("transform", name="a")
    >>> b = cmds.createNode("transform", name="b")
    >>> c = cmds.createNode("transform", name="c")
    >>> cmds.select(a)
    >>> gc = cmds.sets([a], name="grandchild")
    >>> cc = cmds.sets([gc, b], name="child")
    >>> parent = cmds.sets([cc, c], name="parent")
    >>> mainset = encode(parent)
    >>> sorted(mainset.flatten(), key=lambda n: n.name())
    [|a, |b, |c]
def flatten(self, type=None):
    'Return members, converting nested object sets into its members\n\n        Example:\n            >>> from maya import cmds\n            >>> _ = cmds.file(new=True, force=True)\n            >>> a = cmds.createNode("transform", name="a")\n            >>> b = cmds.createNode("transform", name="b")\n            >>> c = cmds.createNode("transform", name="c")\n            >>> cmds.select(a)\n            >>> gc = cmds.sets([a], name="grandchild")\n            >>> cc = cmds.sets([gc, b], name="child")\n            >>> parent = cmds.sets([cc, c], name="parent")\n            >>> mainset = encode(parent)\n            >>> sorted(mainset.flatten(), key=lambda n: n.name())\n            [|a, |b, |c]\n\n        '
    members = set()

    def recurse(objset):
        for member in objset:
            if member.isA(om.MFn.kSet):
                recurse(member)
            elif (type is not None):
                if (type == member.typeName):
                    members.add(member)
            else:
                members.add(member)
    recurse(self)
    return list(members)