code: public int getOntologyTermDistance(OntologyTerm ontologyTerm1, OntologyTerm ontologyTerm2) {
      String nodePath1 = getOntologyTermNodePath(ontologyTerm1);
      String nodePath2 = getOntologyTermNodePath(ontologyTerm2);
  
      if (StringUtils.isEmpty(nodePath1)) {
        throw new MolgenisDataAccessException(
            "The nodePath cannot be null : " + ontologyTerm1.toString());
      }
  
      if (StringUtils.isEmpty(nodePath2)) {
        throw new MolgenisDataAccessException(
            "The nodePath cannot be null : " + ontologyTerm2.toString());
      }
  
      return calculateNodePathDistance(nodePath1, nodePath2);
    }
docs: Calculate the distance between any two ontology terms in the ontology tree structure by
  calculating the difference in nodePaths.
  
  @return the distance between two ontology terms