A General Approach To Nonparametric Histogram Estimation