code: private static void garbageCollectUnusedLevels() {
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.entry(tc, "garbageCollectUnusedLevels");
  
          final int numLevels = _syncLevels.size();
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
              Tr.debug(tc, "Levels: " + numLevels);
  
          // No need to do anything if we only have one level
          if (numLevels < 2) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                  Tr.exit(tc, "garbageCollectUnusedLevels", "Doing nothing");
              return;
          }
  
          final int[] counts = new int[numLevels];
  
          // Check through all transactions to see which levels are still in use
          final TransactionImpl[] txns = LocalTIDTable.getAllTransactions();
  
          // Record the levels with transactions referring to them
  
          // Record the levels with transactions referring to them
          for (int i = txns.length; --i >= 0;) {
              // TransactionImpl has a dependency on CORBA which we definitely don't want
              // Skip this step to avoid a classcastexception
              // TODO can we work around the dependency?
              int level = 0;
              // final int level = ((com.ibm.ws.tx.jta.TransactionImpl) txns[i]).getExtJTASyncLevel();
              if (tc.isDebugEnabled()) {
                  Tr.debug(tc, "Not generating any counts for garbageCollectUnusedLevels()");
              }
  
              if (level >= 0 && level < numLevels) {
                  counts[level]++;
              }
          }
  
          // Now null out the levels with no references
          for (int i = counts.length; --i >= 0;) {
              // We never want to null out the current level
              if (i != _syncLevel) {
                  if (counts[i] == 0) {
                      _syncLevels.set(i, null);
                  }
              }
          }
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
              Tr.exit(tc, "garbageCollectUnusedLevels", _syncLevels.size());
      }
docs: Null out levels that will never be referenced again.
  Null entries are candidates to be the next current level.