code: function removeInnerLocations(locations: AstLocation[], position: AstPosition) {
    // First, let's find the nearest position-enclosing function location,
    // which is to find the last location enclosing the position.
    const newLocs = locations.slice();
    const parentIndex = findLastIndex(newLocs, loc =>
      containsPosition(loc, position)
    );
    if (parentIndex < 0) {
      return newLocs;
    }
  
    // Second, from the nearest location, loop locations again, stop looping
    // once seeing the 1st location not enclosed by the nearest location
    // to find the last inner locations inside the nearest location.
    const innerStartIndex = parentIndex + 1;
    const parentLoc = newLocs[parentIndex];
    const outerBoundaryIndex = findIndex(
      newLocs,
      loc => !containsLocation(parentLoc, loc),
      innerStartIndex
    );
    const innerBoundaryIndex =
      outerBoundaryIndex < 0 ? newLocs.length - 1 : outerBoundaryIndex - 1;
  
    // Third, remove those inner functions
    newLocs.splice(innerStartIndex, innerBoundaryIndex - parentIndex);
    return newLocs;
  }
docs: Find the nearest location containing the input position and
  return new locations without inner locations under that nearest location
  
  @param locations Notice! The locations MUST be sorted by `sortByStart`
  so that we can do linear time complexity operation.