private void calculateNextLevel(
      SkyNetID ownID, SkyNetID skyNetCoKey, BigDecimal left, BigDecimal right, int iter) {
    if (iter == 0) {
      coordinatorKey = skyNetCoKey;
      level = iter;
    } else {
      coordinatorKey = skyNetCoKey;
      level = iter;
    }
    if (iter < 100) {
      // call processNextLevel(...), but before split the interval
      // defined by left and right in k subintervals as defined by
      // branchingFactor.
      BigDecimal interval = right.subtract(left);
      BigDecimal intervalStep = interval.divide(new BigDecimal(String.valueOf(branchingFactor)));
      BigDecimal tempLeft = left;
      BigDecimal tempRight = left.add(new BigDecimal(String.valueOf(intervalStep)));
      log.info(
          SkyNetUtilities.getTimeAndNetID(skyNetNode)
              + "is actually in the interval between "
              + left.toPlainString()
              + " and "
              + right.toPlainString()
              + ". The size of the interval is"
              + interval);
      int correctnessCounter = 0;
      while (ownID.getID().compareTo(tempRight) > -1) {
        tempLeft = tempRight;
        tempRight = tempRight.add(new BigDecimal(String.valueOf(intervalStep)));
        if (correctnessCounter < branchingFactor) {
          correctnessCounter++;
        } else {
          log.fatal(
              "There are actually "
                  + (correctnessCounter + 1)
                  + " intervals instead of "
                  + branchingFactor);
        }
      }
      processNextLevel(ownID, tempLeft, tempRight, iter + 1);

    } else {
      skyNetNode.getMetricUpdateStrategy().scheduleNextUpdateEvent();
      parentCoordinator = null;
      if (isRoot) {
        log.warn(SkyNetUtilities.getTimeAndNetID(skyNetNode) + "lost the root-position");
      }
      isRoot = false;
      log.error(
          SkyNetUtilities.getTimeAndNetID(skyNetNode)
              + "is to deep in the tree."
              + "Probably no predecessor in the overlay can be found"
              + " to calculate the 'isRootOf'-method");
    }
  }
  private void lookupParentCoordinator() {
    if (((AbstractOverlayNode<?, ?>) skyNetNode.getOverlayNode())
        .getPeerStatus()
        .equals(PeerStatus.PRESENT)) {
      log.debug(
          SkyNetUtilities.getTimeAndNetID(skyNetNode)
              + "starts a lookup for the key "
              + coordinatorKey.getPlainSkyNetID());
      treeHandlerDelegator.lookupParentCoordinator(
          coordinatorKey,
          new OperationCallback<OverlayContact<OverlayID<?>>>() {

            @Override
            public void calledOperationFailed(Operation<OverlayContact<OverlayID<?>>> op) {
              lookupOperationFailed(op);
            }

            @Override
            public void calledOperationSucceeded(Operation<OverlayContact<OverlayID<?>>> op) {
              lookupOperationSucceeded(op);
            }
          });
    } else {
      log.warn("SkyNetNode cannot lookup ParentCoordinator" + ", because he is not PRESENT");
    }
  }
  private void checkResponsibility(
      SkyNetID ownID, SkyNetID skyNetCoKey, BigDecimal left, BigDecimal right, int iter) {
    skyNetNode.getSkyNetNodeInfo().setCoordinatorKey(skyNetCoKey);
    log.info(
        " The client "
            + skyNetNode.getSkyNetNodeInfo().toString()
            + " is responsible for the CoordinatorKey "
            + skyNetCoKey.getPlainSkyNetID()
            + " in the interval["
            + left.toPlainString()
            + ";"
            + right.toPlainString()
            + "] @ level "
            + iter);

    ISkyNetMonitor monitor = (ISkyNetMonitor) Simulator.getMonitor();
    ChurnStatisticsAnalyzer csAnalyzer =
        (ChurnStatisticsAnalyzer) monitor.getConnectivityAnalyzer(ChurnStatisticsAnalyzer.class);

    if (iter > 0) {
      // complete the parentSkyNetNode Info
      if (isRoot) {
        log.warn(SkyNetUtilities.getTimeAndNetID(skyNetNode) + "lost the root-position");
        csAnalyzer.lostRootPosition(skyNetNode);
        skyNetNode.getMetricUpdateStrategy().setLastMetricSync(0);
      }
      skyNetNode.getSkyNetNodeInfo().setLevel(iter);
      isRoot = false;
      lookupParentCoordinator();
    } else {
      if (!isRoot) {
        log.warn(SkyNetUtilities.getTimeAndNetID(skyNetNode) + "got the root-position");
        csAnalyzer.gotRootPosition(skyNetNode);
        skyNetNode.getMetricUpdateStrategy().setLastMetricSync(0);
      }
      skyNetNode.getSkyNetNodeInfo().setLevel(iter);

      // Also set the observed level at this point
      skyNetNode.getSkyNetNodeInfo().setObservedLevelFromRoot(0);

      isRoot = true;
      skyNetNode.getAttributeUpdateStrategy().resetOnlyAttributeUpdateStrategy();
      skyNetNode.getMetricUpdateStrategy().sendNextDataUpdate();
    }
  }