Optimizing for multiple sizes is more complicated. A given layout can be analyzed piece-wise as above for each segment of wire of a given size, bearing in mind that the load current at the end of the segment should include all downstream loads.
A heuristic for sizing might be to calculate the single wire size that would work for the whole circuit. Then since wires come in discrete sizes, the actual voltage drop at the end will be less than the target. If you'd like to take advantage of the unused allowable voltage drop to downsize for the last so many segments, you can rephrase that perturbation problem as a voltage drop problem just like the original.
In the perturbation problem, the far end of end of the run is now the starting point for distance measurements, and each load is associated with the length of the conductor segment preceding it. And for a resistance per unit length you take the difference between that of the larger size and the smaller wire size. Then you can take the unused allowable voltage drop, divide it by that differential resistance per unit length, and come up with a maximum allowable sum of perturbation I*D values. Then add up the perturbation I*D values starting at the far end until you just exceed the maximum allowable; that load is the point at which you can downsize the wiring downstream of it, but not upstream of it.
For further optimization, the perturbation problem can be repeated for another smaller wire size, using whatever remaining allowable voltage drop there is.
Cheers, Wayne