private MemcachedNode getNodeForKey(long hash) {
    final MemcachedNode rv;
    if (!ketamaNodes.containsKey(hash)) {
      // Java 1.6 adds a ceilingKey method, but I'm still stuck in 1.5
      // in a lot of places, so I'm doing this myself.
      SortedMap<Long, MemcachedNode> tailMap = ketamaNodes.tailMap(hash);
      if (tailMap.isEmpty()) {
        hash = ketamaNodes.firstKey();
      } else {
        hash = tailMap.firstKey();
      }
    }
    rv = ketamaNodes.get(hash);
    return rv;
  }
Create a new KetamaIterator to be used by a client for an operation.

@param k the key to iterate for
@param t the number of tries until giving up
@param ketamaNodes the continuum in the form of a TreeMap to be used when
         selecting a node
@param hashAlg the hash algorithm to use when selecting within the
         continuumq
src/main/java/net/spy/memcached/KetamaIterator.java