code: private void findBestWithoutFirst(List<DatanodeDescriptor> listOfNodes,
        DatanodeDescriptor[] result) {
  
      readLock();
      try {
        for (int in2 = 0; in2 < listOfNodes.size(); in2++) {
          DatanodeDescriptor n2 = listOfNodes.get(in2);
  
          for (int in3 = in2 + 1; in3 < listOfNodes.size(); in3++) {
            DatanodeDescriptor n3 = listOfNodes.get(in3);
            if (n2.getNetworkLocation().equals(n3.getNetworkLocation())) {
              RackRingInfo rackInfo = racksMap.get(n2.getNetworkLocation());
              assert (rackInfo != null);
              final int rackSize = rackInfo.rackNodes.size();
              final Integer idN2 = rackInfo.findNode(n2);
              final Integer idN3 = rackInfo.findNode(n3);
  
              if (idN2 != null && idN3 != null) {
                int dist = (idN3 - idN2 + rackSize) % rackSize;
                if (dist >= machineWindow) {
                  dist = rackSize - dist; // try n2 - n3
                }
  
                if (dist < machineWindow) {
                  result[0] = null;
                  result[1] = n2;
                  result[2] = n3;
                  return;
                }
              }
            }
          }
        }
      } finally {
        readUnlock();
      }
    }
docs: Finds best match considering only the remote nodes.
  @param listOfNodes Datanodes to choose from
  @param result Array containing results