Perhaps not exactly what you are looking for, but you might be able to adapt the technique to suit your use case.