Need some help about PyNodes API. (Adjacent faces angles)

I would like to make a PyNode for Cavity-masking:
http://www.pixologic.com/zbrush/paint/images/cavitymasking.jpg

The way I thought to do it is using the angles each face has with the adjacent faces to define a gray color.
http://www.uploadgeek.com/uploads456/0/edge_angles.png

For instance if a face has 3 edges that have adjacent faces, take into account the angles those adjacent faces have with respect to the main face, so when there are concave angles the main face gets darker, depending on how sharp those angles are.

The resulting PyNode would be used as a mask to mix two materials, one would go to the dark parts and the other to the bright ones, blending with a Mix node.

Something like this image:
http://71.18.226.28/images/Zbrush%20Models/OldManRustedMetal.jpg

I have some programming knowledge so I guess I can figure out Python’s syntax, but never programmed anything like this.

What I need to know is if there is any method, which could be used inside Pynodes, that brings the angles of the adjacent faces of a face. For instance an array with angles, or an array with the face’s edges which have adjacent faces and then a method to bring the angle that have the faces which use that edge.

I’ve been checking this page with some PyNodes API guidance, but couldn’t find something like that:
http://wiki.blender.org/index.php/BlenderDev/PyNodes/API

Not sure if I’m capable to do it, but want to give it a try.

Thanks for any help!

.