code: public int getDepth(int index) {
      if (index == 0) {
        return 0;
      } else {
        int[] parts = findSubexpression(index);
        return 1 + subexpressions.get(parts[0]).getDepth(parts[1]);
      }
    }
docs: Gets the depth of the subexpression pointed to by {@code index}
  in the tree. The root is at depth of 0, each of its children
  at depth 1, etc.
  
  @param index
  @return