def _flatten(self, value):
    if isinstance(value, _scalars):
        if ((type(value), value) in self._objtable):
            return
    elif isinstance(value, plistlib.Data):
        if ((type(value.data), value.data) in self._objtable):
            return
    elif (id(value) in self._objidtable):
        return
    refnum = len(self._objlist)
    self._objlist.append(value)
    if isinstance(value, _scalars):
        self._objtable[(type(value), value)] = refnum
    elif isinstance(value, plistlib.Data):
        self._objtable[(type(value.data), value.data)] = refnum
    else:
        self._objidtable[id(value)] = refnum
    if isinstance(value, dict):
        keys = []
        values = []
        items = value.items()
        if self._sort_keys:
            items = sorted(items)
        for (k, v) in items:
            if (not isinstance(k, (str, unicode))):
                if self._skipkeys:
                    continue
                raise TypeError('keys must be strings')
            keys.append(k)
            values.append(v)
        for o in itertools.chain(keys, values):
            self._flatten(o)
    elif isinstance(value, (list, tuple)):
        for o in value:
            self._flatten(o)
def _flatten(self, value):
    if isinstance(value, _scalars):
        if ((type(value), value) in self._objtable):
            return
    elif isinstance(value, plistlib.Data):
        if ((type(value.data), value.data) in self._objtable):
            return
    elif (id(value) in self._objidtable):
        return
    refnum = len(self._objlist)
    self._objlist.append(value)
    if isinstance(value, _scalars):
        self._objtable[(type(value), value)] = refnum
    elif isinstance(value, plistlib.Data):
        self._objtable[(type(value.data), value.data)] = refnum
    else:
        self._objidtable[id(value)] = refnum
    if isinstance(value, dict):
        keys = []
        values = []
        items = value.items()
        if self._sort_keys:
            items = sorted(items)
        for (k, v) in items:
            if (not isinstance(k, (str, unicode))):
                if self._skipkeys:
                    continue
                raise TypeError('keys must be strings')
            keys.append(k)
            values.append(v)
        for o in itertools.chain(keys, values):
            self._flatten(o)
    elif isinstance(value, (list, tuple)):
        for o in value:
            self._flatten(o)