Includes TomDoc. Should provide an iterative version. Could try extending the Math module.