code: public static void cleanIneligibleKeys(Map<ByteArray, Map<Value, Set<ClusterNode>>> keyVersionNodeSetMap,
              int requiredWrite) {
          Set<ByteArray> keysToDelete = new HashSet<ByteArray>();
          for (Map.Entry<ByteArray, Map<Value, Set<ClusterNode>>> entry : keyVersionNodeSetMap.entrySet()) {
              Set<Value> valuesToDelete = new HashSet<Value>();
  
              ByteArray key = entry.getKey();
              Map<Value, Set<ClusterNode>> valueNodeSetMap = entry.getValue();
              // mark version for deletion if not enough writes
              for (Map.Entry<Value, Set<ClusterNode>> versionNodeSetEntry : valueNodeSetMap.entrySet()) {
                  Set<ClusterNode> nodeSet = versionNodeSetEntry.getValue();
                  if (nodeSet.size() < requiredWrite) {
                      valuesToDelete.add(versionNodeSetEntry.getKey());
                  }
              }
              // delete versions
              for (Value v : valuesToDelete) {
                  valueNodeSetMap.remove(v);
              }
              // mark key for deletion if no versions left
              if (valueNodeSetMap.size() == 0) {
                  keysToDelete.add(key);
              }
          }
          // delete keys
          for (ByteArray k : keysToDelete) {
              keyVersionNodeSetMap.remove(k);
          }
      }
docs: Determine if a key version is invalid by comparing the version's
  existence and required writes configuration
  
  @param keyVersionNodeSetMap A map that contains keys mapping to a map
  that maps versions to set of PrefixNodes
  @param requiredWrite Required Write configuration