code: S getCommonParent(S other) {
      S left = thisScope();
      S right = other;
      while (left != null && right != null && left != right) {
        int leftDepth = left.getDepth();
        int rightDepth = right.getDepth();
        if (leftDepth >= rightDepth) {
          left = left.getParent();
        }
        if (leftDepth <= rightDepth) {
          right = right.getParent();
        }
      }
  
      checkState(left != null && left == right);
      return left;
    }
docs: Returns the nearest common parent between two scopes.