public static RemovableIdentities ofService(Cluster cluster, ServiceRemovedEvent event, KerberosHelper kerberosHelper) throws AmbariException {
    if (cluster.getSecurityType() != SecurityType.KERBEROS) {
      return RemovableIdentities.none();
    }
    KerberosServiceDescriptor serviceDescriptor = kerberosHelper.getKerberosDescriptor(cluster, false).getService(event.getServiceName());
    if (serviceDescriptor == null) {
      return RemovableIdentities.none();
    }
    UsedIdentities usedIdentities = UsedIdentities.populate(cluster, excludeService(event.getServiceName()), ComponentExclude.NONE, kerberosHelper);
    return new RemovableIdentities(
      serviceDescriptor.getIdentitiesSkipReferences(),
      usedIdentities,
      cluster,
      event.getComponents());
  }
Populate the identities with the identities of the removed service and its components
ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/RemovableIdentities.java