code: public static boolean checkCloseTagClosesOptional(TagName closeTag, TagName optionalOpenTag) {
      // TODO(b/120994894): Replace this with checkArgument() when HtmlTagEntry can be replaced.
      if (!optionalOpenTag.isStatic() || !optionalOpenTag.isDefinitelyOptional()) {
        return false;
      }
      if (!closeTag.isStatic()) {
        return true;
      }
      String openTagName = optionalOpenTag.getStaticTagNameAsLowerCase();
      String closeTagName = closeTag.getStaticTagNameAsLowerCase();
      checkArgument(!openTagName.equals(closeTagName));
      if ("p".equals(openTagName)) {
        return !PTAG_CLOSE_EXCEPTIONS.contains(closeTagName);
      }
      return OPTIONAL_TAG_CLOSE_TAG_RULES.containsEntry(openTagName, closeTagName);
    }
docs: Checks if the an open tag can be auto-closed by a following close tag which does not have the
  same tag name as the open tag.
  
  <p>We throws an {@code IllegalArgumentException} if two inputs have the same tag names, since
  this should never happen (should be handled by previous logic in {@code
  StrictHtmlValidationPass}).
  
  <p>This implements half of the content model described in <a
  href="https://www.w3.org/TR/html5/syntax.html#optional-tags">https://www.w3.org/TR/html5/syntax.html#optional-tags</a>.
  Notably we do nothing when we see cases like "li element is immediately followed by another li
  element". The validation logic relies on auto-closing open tags when we see close tags. Since
  only {@code </ul>} and {@code </ol>} are allowed to close {@code <li>}, we believe this should
  still give us a confident error message. We might consider adding support for popping open tags
  when we visit open tags in the future.