Optimized for max prefix length: avoided looking for prefixes longer
than max prefix length

Preferred decomposition with minimal number of decomposed elements if
the score is equal