prepare_dendrogram function

Prepare dendrogram by transforming dendrogram segments.