Divide quad mesh

You could look inside Mesh Iso splitting script

There are lots of other script that takes a mesh and change it. Mesh+ weaverbird Yellow not sure they are open source. You can also search for algorithm doing recursion on mesh (fractals) …
Look at the sphere script

As a mesh is vertices and topology you must find a strategy to keep track of that.