Cycles. Masking objects with shaders (no compositor) Starting off I want to clear it out that it may be a duplicate question, but in fact it is not. 
1. Here's my previous question Cycles. Masking shader. How to make objects disappear in plain sight. 
2. Here's the one using the compositor Mask out certain objects? 
3. This one uses Blender Render Mask single object

Problem description: 
I need to be able to mask out (make it completely transparent) certain objects in a 3d scene. An object placed inside another object's volume (masking objects are closed mesh, water tight, manifolds) should be transparent. If only a potion of an object is inside the mask (masking object) then only that portion is transparent (invisible on the render).

The main use of this is for motion graphic designs. 
Demonstrations of what is needed: (imitated with booleans) 

The masking object has only one shader - transparent.




Solutions that don't fit and why: 


The question at the first link[1] was by me, and the answer
was to use Transparent Depth as a factor.  The problem with
that solution is that it doesn't care whether an object is inside
something or not, it just renders transparent everything that comes
after the transparent surface (the surface of the masking object)
 As you can see,
from one side it's fine but when rotate the view so that all our
objects are behind the masking one, everything that has that shader
setup is transparent.
The answer that is given at the second link[2] uses render layers and as a consequence requires compositing. When you work in 3d and have a production scene with many objects that grow out control, that approach is simply not suitable. 
At the third link [3] the solution is provided only for the Blender Render and also uses fixed coordinates for a "faked plane" which is done in nodes, not taking into account any real geometry at all. 



My thoughts and commentary: 
The masking object has only one shader - transparent. 
Maybe there is a way to input the geometry of other meshes through pynodes and somehow use it as a factor in mixing emission and transparency.
Using Cycles, you can achieve this by combining transparent depth of the light path node and backfacing of the geometry node.
We want to be transparent what has a depth modulo 2 equal to 1, as we want to be visible what is behind the transparent object (all are considered manifold).
But back faces have an additional transparency depth because they can be behind its own transparent front face.
So we add the two (backface + transparency depth) and set transparent what is modulo 2 = 1.
Here is an example:


Note that in the provided blend file, if the two transparent cubes overlap (intersect), the blue one will reappear. But the two transparent cubes together are no more manifold when overlapping.