/* !
## internalGetPathValue(obj, parsed[, pathDepth])

Helper companion function for `.parsePath` that returns
the value located at the parsed address.

var value = getPathValue(obj, parsed);

@param {Object} object to search against
@param {Object} parsed definition from `parsePath`.
@param {Number} depth (nesting level) of the property we want to retrieve
@returns {Object|Undefined} value
@api private
function internalGetPathValue(obj, parsed, pathDepth) {
  var temporaryValue = obj;
  var res = null;
  pathDepth = (typeof pathDepth === 'undefined' ? parsed.length : pathDepth);

  for (var i = 0; i < pathDepth; i++) {
    var part = parsed[i];
    if (temporaryValue) {
      if (typeof part.p === 'undefined') {
        temporaryValue = temporaryValue[part.i];
      } else {
        temporaryValue = temporaryValue[part.p];
      }

      if (i === (pathDepth - 1)) {
        res = temporaryValue;
      }
    }
  }

  return res;
}