To grow or to fluctuate – optimal demographic paths