/**
 * Given a nested tuple and an index, find the value located at the given index position.
 *
 * @param nestedTuple The nested tuple in which the value is located.
 * @param index The index position to be searched in the nested tuple.
 * @return A tuple containing the value found at the given index position.
 *
 * Example:
 * findNestedValue((('A', ('B', ('C', 'D'))), ('E', ('F', 'G'))), 3) -> ('C', 'D')
 */
fun findNestedValue(nestedTuple: Any, index: Int): Any? {

    if (index == 0) {
        return (nestedTuple as List<*>)[0]
    } else {
        for (item in nestedTuple as List<*>) {
            if (item is List<*>) {
                val subResult = findNestedValue(item, index - 1)
                if (subResult != null) {
                    return subResult
                }
            }
        }
    }
    return null
}
/**
 * Given a nested tuple and an index, find the value located at the given index position.
 *
 * @param nestedTuple The nested tuple in which the value is located.
 * @param index The index position to be searched in the nested tuple.
 * @return A tuple containing the value found at the given index position.
 *
 * Example:
 * findNestedValue((('A', ('B', ('C', 'D'))), ('E', ('F', 'G'))), 3) -> ('C', 'D')
 */
fun findNestedValue(nestedTuple: Any, index: Int): Any? {
/**
 * Given a nested tuple and an index, find the value located at the given index position.
 *
 * @param nestedTuple The nested tuple in which the value is located.
 * @param index The index position to be searched in the nested tuple.
 * @return A tuple containing the value found at the given index position.
 *
 * Example:
 * findNestedValue((('A', ('B', ('C', 'D'))), ('E', ('F', 'G'))), 3) -> ('C', 'D')
 */
fun findNestedValue(nestedTuple: Any, index: Int): Any? {

    if (index == 0) {
        return (nestedTuple as List<*>)[0]
    } else {
        for (item in nestedTuple as List<*>) {
            if (item is List<*>) {
                val subResult = findNestedValue(item, index - 1)
                if (subResult != null) {
                    return subResult
                }
            }
        }
    }
    return null
}