def getForeignKeyElems(pyObj, parentMap={}, models=None):
  if not pyObj:
    return None

  if pyObj.__hash__:
    hashOfObj = hash(pyObj)
    if hashOfObj in parentMap:
        return None

    # Memoize it now
    parentMap[hashOfObj] = hashOfObj

  foreignKeys = getForeignKeys(
    pyObj.__dict__ if hasattr(pyObj, '__dict__') else pyObj
  )

  if not foreignKeys: return None

  dataDict = dict()
  for foreignKey in foreignKeys:
    foreignId = getattr(pyObj, foreignKey, None)
    if not foreignId: continue # Corrupted data detected

    tableName = suffixStrip(foreignKey, globVars.ID_SUFFIX)
    tablePrototype = matchTable(tableName, models=None)
    if not tablePrototype: continue

    connObjs = tablePrototype.objects.filter((globVars.ID_KEY, foreignId))
    if not connObjs: continue

    connObj = connObjs[0]

    # Checking for self/cyclic reference
    if connObj.__hash__ and (hash(connObj) in parentMap):
       continue

    serializdDict = getSerializableElems(connObj)
    dataDict[tableName] = serializdDict

  return dataDict
dataset/ETHPy150Open odeke-em/restAssured/api/crudAPI.py/getForeignKeyElems/original