Fractal structure as least energy patterns: the case of river networks