code: @SuppressWarnings("unused") // used by parser
    public static void removeDuplicatesAndReportErrors(
        Iterable<CommandTagAttribute> attrs, ErrorReporter errorReporter) {
      Set<String> seenAttributes = new HashSet<>();
      for (Iterator<CommandTagAttribute> iterator = attrs.iterator(); iterator.hasNext(); ) {
        CommandTagAttribute attr = iterator.next();
        Identifier name = attr.getName();
        if (!seenAttributes.add(name.identifier())) {
          errorReporter.report(name.location(), DUPLICATE_ATTRIBUTE, name.identifier());
          iterator.remove();
        }
      }
    }
docs: Identifies duplicate attributes, reports an error for each one, and removes them from the
  {@link Iterable}.