OPAL: A new algorithm for optimal partitioning and learning in non parametric unsupervised environments