For reference, here's what I did:
My terrain mask is a PF shader with colour contrast 10 and colour offset -0.5. The important part is to have "Clamp high colour" and "Clamp low colour" unchecked. I used that with a Clamp Colour node to mask my terrain and get some random cliffs. To get the edges around the lower cliffs, I added a Constant Colour of 1 to that PF and clamped the result. Then I simply substracted the clamped original PF from the clamped sum and got what I needed.
Depending on how your original PF is set up, you might have to play around with the Constant Colour value. In my case, high colour in the PF is actually black and I don't apply low colour (I have a mostly white shader as input to the PF).
It might also be possible to use this without having the high contrast PF by somehow creating the high contrast colour map from the displacement, but I don't know enough about TG to attempt that.