code: function (productTypes) {
              var color,
                  distance,
                  bestColor,
                  bestAppearance,
                  tmpDistance,
                  tmpProductType,
                  colorKey;
  
              productTypes.each(function (productType) {
                  bestColor = null;
                  productTypeToColorMap[productType.$.id] = tmpProductType = {};
                  var appearances = productType.getAvailableAppearances();
                  if (appearances) {
                      for (var i = 0; i < colors.length; i++) {
                          distance = Number.MAX_VALUE;
                          bestColor = null;
                          bestAppearance = null;
                          color = colors[i];
  
                          appearances.each(function (appearance) {
                              tmpDistance = color.distanceTo(appearance.getMainColor());
                              if (tmpDistance < distance) {
                                  distance = tmpDistance;
                                  bestColor = color;
                                  bestAppearance = appearance;
                              }
                              if (distance < 30) {
                                  colorKey = bestColor.toString();
                                  if (!tmpProductType[colorKey]) {
                                      tmpProductType[colorKey] = [];
                                  }
                                  if (bestAppearance === appearance) {
                                      tmpProductType[colorKey].unshift(appearance);
                                  } else {
                                      tmpProductType[colorKey].push(appearance);
                                  }
                              }
                          });
  
                      }
                  }
              });
          }
docs: *
  initializes the productTypeColorCache
  @param {js.core.List} productTypes