def METHOD_NAME(arrays, parent_index=[]):
    """
    Copied from NumPy 1.14.1.
    """
    def format_index(index):
        idx_str = ''.join('[{}]'.format(i) for i in index if i is not None)
        return 'arrays' + idx_str
    if type(arrays) is tuple:
        # not strictly necessary, but saves us from:
        #  - more than one way to do things - no point treating tuples like
        #    lists
        #  - horribly confusing behaviour that results when tuples are
        #    treated like ndarray
        raise TypeError(
            '{} is a tuple. '
            'Only lists can be used to arrange blocks, and np.block does '
            'not allow implicit conversion from tuple to ndarray.'.format(
                format_index(parent_index)
            )
        )
    elif type(arrays) is list and len(arrays) > 0:
        idxs_ndims = (METHOD_NAME(arr, parent_index + [i])
                      for i, arr in enumerate(arrays))
        first_index, max_arr_ndim = next(idxs_ndims)
        for index, ndim in idxs_ndims:
            if ndim > max_arr_ndim:
                max_arr_ndim = ndim
            if len(index) != len(first_index):
                raise ValueError(
                    "List depths are mismatched. First element was at depth "
                    "{}, but there is an element at depth {} ({})".format(
                        len(first_index),
                        len(index),
                        format_index(index)
                    )
                )
        return first_index, max_arr_ndim
    elif type(arrays) is list and len(arrays) == 0:
        # We've 'bottomed out' on an empty list
        return parent_index + [None], 0
    else:
        # We've 'bottomed out' - arrays is either a scalar or an array
        return parent_index, _nx.ndim(arrays)