Access system icons with NodeJS

I'm developing a HTML5 app with node-webkit.

I want my application to follow the icon theme of the host computer that runs it (primarly Linux hosts).

Frameworks such as GTK+ or QT successfully find the corresponding icon of a standard stock (such as NEW_FILE) based on the user's theme.

GTK icons theme are installed at $HOME/.icons or /usr/share/icons and icons theme share a common directory structure.

But is it any rule or algorithm to get an exact icon?

How can I look up a (NEW_FILE, SAVE_FILE or whatever) stock icon within the users theme?

I'm quite lost with this.

You could look in the source code for GTK+ or QT and see how they determine the right icons?