An implementation of the Bestvina-Handel algorithm in Python