Python interval and interval set implementation