Function to flip dendrogram branches