An algorithm for thimble regularization of lattice field theories (and possibly not only for that)