Method of hierarchical clustering