Blender Game Engine: poly and vertex listing


I need to list all polygons and all vertex of a mesh in Blender Game Engine to construct a tree structure and calculate the bounding box.

I use the following function: sometimes I receive wrong result, specially with hi-poly mesh, like a max poly count limit.
At the end I get wrong bounding box coordinates.

Is that function correct?

Thank you,

def getBgeObjectData(obj):
    """ This functions retrieve an array of [polyIndex][vertexes] of an object """
    """ """

    tris = []
    for mesh in obj.meshes:

        countme = 0
        for polyIndex in range(mesh.numPolygons):
            countme += 1

            polygon = mesh.getPolygon(polyIndex)
            matIndex = polygon.getMaterialIndex()

            vertsPosition = []

            count = 0
            for polyVertIndex in range(polygon.getNumVertex()):
                count += 1

                meshVertIndex = polygon.getVertexIndex(polyVertIndex)

                #print(matIndex, meshVertIndex)
                vertex = mesh.getVertex(matIndex, meshVertIndex)

                #print( "Count:", countme, " Poly:", count, " MatIndex:", matIndex, " MeshVertIndex:", meshVertIndex, " ", vertex.XYZ)

                vertexPosition = vertex.XYZ

    print( "CountPoly:", countme )
    return tris