An Example from the Microtype Documentation

I suppose you are asking for the implementation of the layers/OCGs in the microtype documentation. AFAIK this is not done via pgf. Check microtype.dtx v1.66 for the code after line 517 with the comment

% the samples in the introduction, utilising nested optional content groups (aka. layers):

There he implements optional content.


Well, as usual it is all there, right before ones eyes... my pgfmanual was old, the current one has section 16.13 Referencing Nodes Outside the Current Pictures starting with 16.13.1 Referencing a Node in a Different Picture and section 75.3.2 explains the behind the scenes details.