public static Throwable causeAt(Throwable parent, final int requiredIndex) {
    //
    // TODO:
    // NEED TO CHECK WHETHER RIGHT PARENT CAUSE RETRUNED
    //
    if (parent != null && requiredIndex > 0) {
      // recurse deeper
      return causeAt(parent.getCause(), requiredIndex - 1);
    }

    // when there isn't required depth
    if (requiredIndex > 0) {
      return null;
    }

    return parent;
  }
Returns cause at the specified depth/index starting from the 'top most' Throwable
<code>parent</code> in the stack. Returns <code>null</code> if it can't find it.

@param parent Throwable to use to find the cause at given index/depth
@param requiredIndex index/depth of nesting the cause
@return cause at the specified index starting from the 'top most' Throwable in the stack.
        <code>null</code> if it can't find it.
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/util/CauseFinder.java