function queryPathKeys(array, current, parentId, id = 'id') {
  const result = [current]
  const hashMap = new Map()
  array.forEach(item => hashMap.set(item[id], item))

  const getPath = current => {
    const currentParentId = hashMap.get(current)[parentId]
    if (currentParentId) {
      result.push(currentParentId)
      getPath(currentParentId)
    }
  }

  getPath(current)
  return result
}
In an array object, traverse all parent IDs based on the value of an object.
@param   {array}     array     The Array need to Converted.
@param   {string}    current   Specify the value of the object that needs to be queried.
@param   {string}    parentId  The alias of the parent ID of the object in the array.
@param   {string}    id        The alias of the unique ID of the object in the array.
@return  {array}    Return a key array.