Imported from https://github.com/alexdepremia/Advanced-Density-Peaks