function positionRangeForPath(yaml, path) {

  // Type check
  if (typeof yaml !== "string") {
    throw new TypeError("yaml should be a string")
  }
  if (!isArray(path)) {
    throw new TypeError("path should be an array of strings")
  }

  var invalidRange = {
    start: {line: -1, column: -1},
    end: {line: -1, column: -1}
  }
  var i = 0

  let ast = cachedCompose(yaml)

  // simply walks the tree using astValue path recursively to the point that
  // path is empty.
  return find(ast)

  function find(astValue, astKeyValue) {
    if (astValue.tag === MAP_TAG) {
      for (i = 0; i < astValue.value.length; i++) {
        var pair = astValue.value[i]
        var key = pair[0]
        var value = pair[1]

        if (key.value === path[0]) {
          path.shift()
          return find(value, key)
        }
      }
    }

    if (astValue.tag === SEQ_TAG) {
      var item = astValue.value[path[0]]

      if (item && item.tag) {
        path.shift()
        return find(item, astKeyValue)
      }
    }

    // if path is still not empty we were not able to find the node
    if (path.length) {
      return invalidRange
    }

    const range = {
      start: {
        line: astValue.start_mark.line,
        column: astValue.start_mark.column,
        pointer: astValue.start_mark.pointer,
      },
      end: {
        line: astValue.end_mark.line,
        column: astValue.end_mark.column,
        pointer: astValue.end_mark.pointer,
      }
    }

    if(astKeyValue) {
      // eslint-disable-next-line camelcase
      range.key_start = {
        line: astKeyValue.start_mark.line,
        column: astKeyValue.start_mark.column,
        pointer: astKeyValue.start_mark.pointer,
      }
      // eslint-disable-next-line camelcase
      range.key_end = {
        line: astKeyValue.end_mark.line,
        column: astKeyValue.end_mark.column,
        pointer: astKeyValue.end_mark.pointer,
      }
    }

    return range
  }
}
Get a position object with given
@param  {string}   yaml
YAML or JSON string
@param  {array}   path
an array of stings that constructs a
JSON Path similar to JSON Pointers(RFC 6901). The difference is, each
component of path is an item of the array instead of being separated with
slash(/) in a string