Optimise paths.

By grouping h1h1h1 to h3 for example.