def Flatten(o):
  if o is None or not OBJC_OK:
    pass
  elif type(o, Foundation.NSCFDictionary):
    n = {}
    for k, v in o.iteritems():
      n[Flatten(k)] = Flatten(v)
    o = n
  elif isinstance(o, Foundation.NSCFArray):
    n = []
    for i in xrange(len(o)):
      n.append(Flatten(o[i]))
    o = n
  elif isinstance(o, objc.pyobjc_unicode):
    o = unicode(o)
  elif hasattr(o, 'initWithInteger_'):
    o = int(o)
  return o
Flatten pyobjc objects into Python native equivalents.
dataset/ETHPy150Open google/simian/src/simian/mac/client/flight_common.py/Flatten