docs: public void clearAndCancelAgendaGroup(InternalAgendaGroup agendaGroup) {
          // enforce materialization of all activations of this group before removing them
          for (Activation activation : agendaGroup.getActivations()) {
              ((RuleAgendaItem)activation).getRuleExecutor().reEvaluateNetwork( this );
          }
  
          final EventSupport eventsupport = this.workingMemory;
  
          agendaGroup.setClearedForRecency( this.workingMemory.getFactHandleFactory().getRecency() );
  
          // this is thread safe for BinaryHeapQueue
          // Binary Heap locks while it returns the array and reset's it's own internal array. Lock is released afer getAndClear()
          List<RuleAgendaItem> lazyItems = new ArrayList<RuleAgendaItem>();
          for ( Activation aQueueable : agendaGroup.getAndClear() ) {
              final AgendaItem item = (AgendaItem) aQueueable;
              if ( item.isRuleAgendaItem() ) {
                  lazyItems.add( (RuleAgendaItem) item );
                  ((RuleAgendaItem) item).getRuleExecutor().cancel(workingMemory, eventsupport);
                  continue;
              }
  
              // this must be set false before removal from the activationGroup.
              // Otherwise the activationGroup will also try to cancel the Actvation
              // Also modify won't work properly
              item.setQueued(false);
  
              if ( item.getActivationGroupNode() != null ) {
                  item.getActivationGroupNode().getActivationGroup().removeActivation( item );
              }
  
              eventsupport.getAgendaEventSupport().fireActivationCancelled( item,
                                                                            this.workingMemory,
                                                                            MatchCancelledCause.CLEAR );
          }
          // restore lazy items
          for ( RuleAgendaItem lazyItem : lazyItems ) {
              agendaGroup.add( lazyItem );
          }
      }