setObjKey = function (obj, key, value) {
    var keyparts = key.split('.');

    // Recursive version of setObjKey
    var recSetObjKey = function (obj, keyparts, value) {
      var arrayMatch = null;
      var reArray = /\[([0-9]*)\]$/;
      var subkey = keyparts.shift();
      var idx = 0;

      if (keyparts.length > 0) {
        // Not the end yet, build the hierarchy
        arrayMatch = subkey.match(reArray);
        if (arrayMatch) {
          // Subkey is part of an array, check all existing array items
          // TODO: review that! Only create the right item!!!
          subkey = subkey.replace(reArray, '');
          if (!_isArray(obj[subkey])) {
            obj[subkey] = [];
          }
          obj = obj[subkey];
          if (arrayMatch[1] !== '') {
            idx = parseInt(arrayMatch[1], 10);
            if (!obj[idx]) {
              obj[idx] = {};
            }
            recSetObjKey(obj[idx], keyparts, value);
          }
          else {
            for (var k = 0; k < obj.length; k++) {
              recSetObjKey(obj[k], keyparts, value);
            }
          }
          return;
        }
        else {
          // "Normal" subkey
          if (typeof obj[subkey] !== 'object') {
            obj[subkey] = {};
          }
          obj = obj[subkey];
          recSetObjKey(obj, keyparts, value);
        }
      }
      else {
        // Last key, time to set the value, unless already defined
        arrayMatch = subkey.match(reArray);
        if (arrayMatch) {
          subkey = subkey.replace(reArray, '');
          if (!_isArray(obj[subkey])) {
            obj[subkey] = [];
          }
          idx = parseInt(arrayMatch[1], 10);
          if (!obj[subkey][idx]) {
            obj[subkey][idx] = value;
          }
        }
        else if (!obj[subkey]) {
          obj[subkey] = value;
        }
      }
    };

    // Skip first item if empty (key starts with a '.')
    if (!keyparts[0]) {
      keyparts.shift();
    }
    recSetObjKey(obj, keyparts, value);
  }
Sets the key identified by a path selector to the given value.

Levels in the path are separated by a dot. Array items are marked
with []. For instance:
 foo.bar[].baz

The hierarchy is automatically created if it does not exist yet.

Default values are added to all array items. Array items are not
automatically created if they do not exist (in particular, the
minItems constraint is not enforced)

@function
@param {Object} obj The object to build
@param {String} key The path to the key to set where each level
 is separated by a dot, and array items are flagged with [x].
@param {Object} value The value to set, may be of any type.