Get diffuse output as mixing factor in cycles

Hi, I’m creating a toon shader with blender nodes. In this tutorial, the shadows on the diffuse material can be used as a mixing factor, letting me control where the shadows lie with thresholding on the individual materials.
It looks like this:

The only problem is that his method uses the blender internal engine, while I would much prefer to work in cycles.

Is this possible? I can think of many uses for this even outside of toon shading, such as greater control for baking lightmaps for game assets.