Fixed GMX Writer

Came up with a single method to obtain the primary node for a resource
type. This is rather ugly and should be made more flexible so the whole
thing supports multiple primary nodes. This effectively resolves the
issue where the very first resource is in a folder, where it was
thinking that group folder was the primary one, so now it iterates
through all parents until it finds it.