code: private void updateObjectId(int lastStep, int nextStep)
      {
          final int max = getMaxStep();
          if (nextStep < max)
          {
              // Next step is free
              if (checkObjectId(path.getX(nextStep), path.getY(nextStep)))
              {
                  takeNextStep(lastStep, nextStep);
              }
              else
              {
                  avoidObstacle(nextStep, max);
              }
          }
      }
docs: Update reference by updating map object Id.
  
  @param lastStep The last step.
  @param nextStep The next step.