code: function determineLayerName(layer) {
  	var name = '';
  
  	// Layer name available
  	if (layer.Name) {
  		return layer.Name;
  	} else {
  		// Layer name not available
  		// Layer name will be building from sublayers
  		for (var int = 0; int < layer.Layer.length; int++) {
  			name += determineLayerName(layer.Layer[int]) + ',';
  		}
  	}
  
  	// Remove last comma
  	if (name.substring(name.length - 1, name.length) == ',') {
  		name = name.substring(0, name.length - 1);
  	}
  
  	return name;
  }
docs: It determines the name of a layer. If the layer name is not set, it will
  generate from the sublayers.
  
  @param {object}
  layer Layer object like {"Name": "LayerName", "Layer": [{"Name":
  "SubLayerName1"},{"Name": "SubLayerName2"}]}
  @returns {string} Name of layer