Ok, this is not a specific problem and I guess it's not possible.
I were tinkering around and suddenly a thought hit me, is it possible to use an custom AOV, a white cutout of an object, as a mask in the shader network?
If it's possible some steps of comping could be avoided and strange stuff can be created :)
I found techniques to mask with transparency, but an AOV would add so much more possibilities.