I've recently heard about a command which can detect blocks in an area, the
/testforblocks (with an s at the end, to not confuse with
/testforblock) command. In this command, there the x1, y1, z1, x2, y2, z2, but also a supplementary x y z:
testforblocks <x1> <y1> <z1> <x2> <y2> <z2> <x> <y> <z> [mode]
Because of this little detail, I can't complete my small project. Thank you very much paying attention at my question.