@Override
    protected void beforeTrackingServiceTicket(final Ticket ownerTicket,
                                               final ServiceTicket serviceTicket) {
        val ticketGrantingTicket = (TicketGrantingTicket) ownerTicket;
        val path = normalizePath(serviceTicket.getService());
        val toRemove = ticketGrantingTicket.getServices()
            .entrySet()
            .stream()
            .filter(entry -> {
                val normalizedExistingPath = normalizePath(entry.getValue());
                return path.equals(normalizedExistingPath);
            }).toList();

        toRemove.forEach(Unchecked.consumer(entry -> {
            ticketGrantingTicket.getServices().remove(entry.getKey());
            ticketRegistry.deleteTicket(entry.getKey());
        }));
    }
This is {@link MostRecentServiceSessionTrackingPolicy}.

@author Misagh Moayyed
@since 7.0.0
core/cas-server-core-tickets-api/src/main/java/org/apereo/cas/ticket/tracking/MostRecentServiceSessionTrackingPolicy.java