function isAlwaysZeroWidth(element) {
  switch (element.type) {
    case 'Assertion':
      // assertions == ^, $, \b, lookarounds
      return true;
    case 'Quantifier':
      return element.max === 0 || isAlwaysZeroWidth(element.element);
    case 'CapturingGroup':
    case 'Group':
      // every element in every alternative has to be of zero length
      return element.alternatives.every(alt => alt.elements.every(isAlwaysZeroWidth));
    case 'Backreference':
      // on if the group referred to is of zero length
      return isAlwaysZeroWidth(element.resolved);
    default:
      return false; // what's left are characters
  }
}
Returns whether the given element will always have zero width meaning that it doesn't consume characters.

@param {Element} element
@returns {boolean}