code: public int calculateNodePathDistance(String nodePath1, String nodePath2) {
      String[] nodePathFragment1 = nodePath1.split("\\.");
      String[] nodePathFragment2 = nodePath2.split("\\.");
  
      int overlapBlock = 0;
      while (overlapBlock < nodePathFragment1.length
          && overlapBlock < nodePathFragment2.length
          && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) {
        overlapBlock++;
      }
  
      return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2;
    }
docs: Calculate the distance between nodePaths, e.g. 0[0].1[1].2[2], 0[0].2[1].2[2]. The distance is
  the non-overlap part of the strings
  
  @return distance