I'm not sure what you think this code does, but the style variable get overwritten each time, meaning that all this function does is return `node.getElementsByTagName('PolyStyle')` every time.  On top of that, looking at the spec, you should be processing all possible styles per placemark.  A Placemark can have both a IconStyle and a LabelStyle, not just one or the other.