I've an SVG image with many objects, ones over anothers. What I need is a final SVG, with the same visual result, but in a way that I could change the opacity of any object without revealing the hidden parts of the other objects, revealing just the "hole" behind.
I've done this diagram to illustrate my question:

I've done the example above by hand with Inkscape, selecting every square and duplicating it as many times as the number of differences (ctrl + -) I've need to apply to "cut" the underlying objects. This method is very hard to apply with a larger amount of objects.
Any software (Adobe Illustrator, command line tool...) or method that solves this problem will be welcome.

