[Question]
  [
Given a possibly nested, non-empty array of single-digit positive integers (not guaranteed unique), output the ASCII-art representation as a tree, using the box-drawing characters `┌ ┴ ┐ ─ │ ┬ ┼`. (These were copied from Code Page 437, but you can use any equivalent representation).
Every integer of the array should be a leaf of the tree. Elements the same level deep in the array should be present at the same level of the tree. All elements should be separated by enough whitespace to be distinct (up to you to determine how wide, minimum of one space between).
For example, given array `[[1, [2]], [3, [4, 5]]]`, output the following tree
```
 ┌─┴─┐
┌┴┐ ┌┴─┐
1 │ 3 ┌┴┐
  2   4 5
```
For array `[1, 2, 3]` the tree could look like
```
┌─┼─┐
1 2 3
```
But the array `[[1, 2, 3]]` would look like
```
  │
┌─┼─┐
1 2 3
```
While the array `[1, [1, [1, [1]]]]` could look like
```
 ┌─┴┐
 1 ┌┴─┐
   1 ┌┴┐
     1 │
       1
```
As a more complicated example, `[1, [[[2, 3], 4], 5]]` could be
```
┌┴───┐
1  ┌─┴┐
 ┌─┴┐ 5
┌┴┐ 4
2 3
```
or several other variations.
---
* Input and output can be given by [any convenient method](http://meta.codegolf.stackexchange.com/q/2447/42963).
* You can print it to STDOUT or return it as a function result.
* Either a full program or a function are acceptable.
* Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins.
  
[Answer]
# [Python 3](https://docs.python.org/3/), 400 393 390 bytes
```
L=len
S,*K=' ┴┼│123456789'
def T(x):
 try:return[str(x+0)]
 except:
  z=[*map(T,x)];q=max(map(L,z))
  for p in z:p+=[S*L(p[0])]*(q-L(p))
  b=[S.join(a)for a in zip(*z)];t=b[0];l=L(t);s=0;e=L(z);r=[S]*l
  if e<2:return['│'.center(l),*b]
  for i in range(l):
   if t[i]in K:s+=1;r[i]='┬┌┐'[(s<e)-(s>1)]
   elif 0<s<e:r[i]='─'
  c=l//2;r[c]=K[r[c]=='┬'];return[''.join(r),*b]
```
Returns a list of strings from top to bottom.
EDIT 1: Trimmed 7 bytes by avoiding duplication of `┴┼` (net save of 2 bytes), cutting out 0 from the one string, changing how drawing characters are selected from `┬┌┐` (use `<` instead of `==`), and replacing a `L(z)` I missed with `e`
EDIT 2: -2 bytes thanks to ovs and -1 byte thanks to Kevin Cruijssen
[Try it online!](https://tio.run/##NY87coMwFEV7VqFOH2Mb2/kiKxswnd1pVACREzJYloUyg6kyqVOkYBkpU2Y1bIQ8SFy9z33nzn327J@PZtX3iSi1CbYh2wiMuva7a3@69n2xXF1d39ze3ePgUe/RjtQ0DpB359hp/@qMrLwj9SSiKkC6zrX1IKNGSHZILdmFNVX8JA5pTYY5CRtKQd8fHbKoMKiJ7UTILUuIlZGiipHTFPrxKANh9nIsDEnpAKQjUFjCGjD1IgOClyIhnvJKRFxD21DuAFOsBINij/R6eQmK4Rs8y7Xx2pGShixT/0mKwdil5knDfog/kF4WCtabuJqIBXcwCXD46tqPrv3EklRrTaekelgMnyOkS2CiNWzjy@0bBiEX5Xy@BD5XYiPHMvpgxS@58N@TbozU978 "Python 3 – Try It Online")
### Ungolfed
```
def layer(item):
    if isinstance(item, int):
        return [str(item)]
    else:
        subs = [layer(sub) for sub in item]
        longest = max(map(len, subs))
        for sub in subs:
            sub += [' ' * len(sub[0])] * (longest - len(sub))
        below = [' '.join(l) for l in zip(*subs)]
        top = below[0]
        l = len(top)
        if len(subs) == 1:
            return ['│'.center(l), *below]
        seen = 0
        expected = len(subs)
        builder = [' '] * l
        for i in range(l):
            c = top[i]
            if c in '┴┼│123456789':
                seen += 1
                if seen == 1:
                    builder[i] = '┌'
                elif seen == expected:
                    builder[i] = '┐'
                else:
                    builder[i] = '┬'
            elif 0 < seen < expected:
                builder[i] = '─'
        center = l // 2
        if builder[center] == '┬':
            builder[center] = '┼'
        else:
            builder[center] = '┴'
        return [''.join(builder), *below]
```
Builds a tree from the leaves up, one layer at a time.
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), ~~544~~ 506 bytes
*Escapes are used to avoid invalid UTF-8 on SE/TIO but counted as one byte as they're valid literals*
```
import StdEnv,Data.List;::T=I Int|L[T];$l#m= @l#k=map maxList(transpose m)=flatlines[[last[' ':[(\_|v<0|w<[j]|q>hd w|q<last w|any((==)q)w|q==j='\305'='\302'|q==j='\301'='\304'='\277'='\332'='\263'=toChar v+'0')0\\[v,r,j:w]<-m|r/2==p&&q>=hd w&&q<=last w]]\\q<-[0..k!!3]]\\p<-[0..k!!1]];@(L l)#p=twice(\p=[[v,r+1:[e+sum([2\\[v:_]<-i|0<=v]++zipWith(\c j=j!!2-c!!3)t(takeWhile(\[z:_]=v+z< -1)(tl t)))-x!!1\\e<-x]]\\i<-inits p&t<-tails p&[v,r:x]<-p])(concatMap@l)#g=[g\\[_,2,g:_]<-p]=[[-1,0,(hd g+last g)/2:g]:p];@(I i)=[[i,0,0,0]];
```
[Try it online!](https://tio.run/##rVTLbtNAFN33KyZpVc8odvEjocLxVJUoi0hBQkqlLuxRNXVcZ1K/Yk8erbJArFmw4DNYsuRr@BDMHTsNhbJggSzdx5lzH/O4DpOIZ3WaT5dJhFIusmEt0iIvJZrI6ZtspV9wyU/GopJD172kIzTK5HbsX7LhUXKYUnSeHN7RlBcQu1EsLEueVUVeQTZCbxMuE5FFle8nvJK@hjTXx8H1duWZ27Xnz9l2cTabovV24SkCGDy7x5hSsiAAUjqnWuCYA61RtvYLslqor5R9etp4jt14Lx2Nyvz1jJdo1dNMjZhB4K/0Up@7a@YZ6bZ8YVNaHB8vzqgqDoZH2/KMBcHCM3zz5OSu03GUW@xdi7HhOR6jhBwWVK5FGOGgoL5K3bNcP@pVyxT7tirmXkMhsTU9umK93oMoroSc4SBEczrvdGwjhOQEDovfRVczkUAi/wFi6Kr34CHDIlgmSBJCjA2UDYLIMzaqFwFJMyErVBxLz5BcJMpUDbgbKFgwgsM8C7l8y4tzaDOmfgztXOu2HjctFQz6NSzd1DHsPO41u47JC9uNmVuo7Y2QIMARQIEPdlxPJIfnQBFeZinPYngnOZL5RJYii8E8IgiP/RGy9EfZaqSUzVhrOK3q62iEBuwRtf5Qe6dNYiv2qRKO/nuJ56H/muFvS0zJfiNfNb099XbNPgl6yh88W/0fKcnw4GA3hpfRRg4P9kdfyRKu4jZPpgkOKoRDvSQAlFGR8DCaLG929xKiElWkofu4q2aiq3e/f/7QJToCH2apqyMAvuyBQQt8ewScHePjnmG1wNcdAFPXAp/2jH4LvO8SVv8IYfrjqjZG4/riPuOpCFvnHfwUbvMyrY2b2pjVA9NMfwI "Clean – Try It Online")
Takes input in the format `L[I 3, L[I 4, I 5], I 2]..`
Connects the trees from the bottom up, left to right, then adjusts the distances from right to left.
Prettified, sort-of:
```
import StdEnv, Data.List;
:: T = I Int | L [T];
$ l
    #m = @l
    #k = map maxList (transpose m)
    = flatlines [
        [
            last[
                ' ':
                [
                    if(v < 0)
                        if(w < [j])
                            if(q > hd w)
                                if(q < last w)
                                    if(any ((==) q) w)
                                        (
                                            if(q == j)
                                                '\305'
                                                '\302'
                                        )(
                                            if(q == j)
                                                '\301'
                                                '\304'
                                        )
                                    '\277'
                                '\332'
                            '\263'
                        (toChar v + '0')
                    \\ [v, r, j: w] <- m
                    | r/2 == p && q >= hd w && q <= last w
                ]
            ]
            \\ q <- [0..k!!3]
        ]
        \\p<-[0..k!!1]
    ];
@ (L l)
    #p = twice
        ( \p
            = [
                [
                    v, r + 1:
                    map
                        (
                            (+)
                            (
                                sum [2 \\ [v: _] <- i| 0 <= v]
                                + sum (
                                    zipWith
                                        (
                                            \[_, _, _, c: _] [_, _, j: _] = j - c
                                        )
                                        t
                                        (
                                            takeWhile (\[v: _] = v < 0) (tl t)
                                        )
                                ) * (1 - sign (v + 1))
                                - x!!1
                            )
                        )
                        x
                ]
            \\ i <- inits p
            &  t <- tails p
            &  [v, r: x] <- p
            ]
        )
        (concatMap @ l)
    #g = [g \\ [_, 2, g: _] <- p]
    =[[-1, 0, (hd g + last g)/2: g]: p];
@ (I i) = [[i, 0, 0, 0]];
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~127~~ 123 bytes
```
↶≔⟦⟦θ⟧⟧ηＦη«≔⊟ιζ¿⁼Ｉζ⪫⟦ζ⟧ω⊞υ⊞ＯιζＦＬζ⊞η⁺ι⟦⊖Ｌζκ§ζκ⟧»Ｗυ«≔⌊υι≔Φυ¬⁼κιυＪ±⊗Ｌυ⊘⊖ＬιＩ⊟ιＷι«≔⊟ιζ¿ζ«←§┐┬‹ζ⊟ιＷ⁼ＫＫψ←─≔⁰ι»¿⊟ι┌¶┴¦│
```
[Try it online!](https://tio.run/##bZLNTsJAFIXX9CluWE2TMfF3oysiGiWIXeiq6aLChU6YttCZAcU0Ma5duOAxXPpEvEidOy0BjUnTJveeOefraYdJXAzzWFZVRykxyVgYzqOIQ@JfeOO8AJb48Oq1mmWQz5jwOazstiXGwK7mJpaKXcZKs5Vd9HJhLVbWYOn7PgRGJcxw97yfYRHrvGCCzpMBSoXgQvqYTXRiHZojiT0ijSJpOOXQxWGBKWYaR3tSDh19m43wma04TP2IPEtvmQiJwMw@9p3IRGpSO@QgKLmZXwupsSDAQa637zIlDbkbUvZMOnvI2QAnsUbWzc2T3EEYp7uJ5cLO/oEkHzIJCpFpdv444@Caqmt0qwZXONy/NY9I8XeIbkjlE/SIKtvZtzfr97YTuHJJhbX1FqKPY71rzuo/N@uvNoc@KsWQMh1Xa0vWtBIgTplNf9nl1U7W4a1O3IIeNiW3SnAQe@lW/NGIf0N/19PSs1dZVWF4ZL98GB5zOKG/MTy1t7MoiqqDhfwB "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
↶
```
Change the default drawing direction to up since we don't draw anything to the right.
```
≔⟦⟦θ⟧⟧η
```
The first step is to convert the nested array representation into an index representation which is a list of all the entries together with the indices of the subarrays, e.g. for the input `q=[1, [[[2, 3]], [4], 5]]` the `5` is `q[1][2]` and therefore the list we want is `1, 2`. We start with a single entry to process which is a list containing a list of the current indices (i.e. none so far) and the original input.
```
Ｆη«
```
Loop over the arrays as we process them. (Conveniently Charcoal will continue to iterate over a list if you push to it during iteration.)
```
≔⊟ιζ
```
Get the next array to process.
```
¿⁼Ｉζ⪫⟦ζ⟧ω
```
Is this actually a scalar rather than an array?
```
⊞υ⊞Ｏιζ
```
If so, then the list we had actually belongs on the final list of lists of indices.
```
ＦＬζ
```
Otherwise, loop over each element in this array...
```
⊞η⁺ι⟦⊖Ｌζκ§ζκ⟧»
```
... and save it with its new index list so far for further processing. The maximum index of the array is also saved which is used to special-case the last element of the array.
```
Ｗυ«
```
We are now ready to loop over the list of index lists. However, the list is not in lexicographical order, so we can't iterate it directly.
```
≔⌊υι
```
Find the next element in lexicographical order.
```
≔Φυ¬⁼κιυ
```
Remove it from the list.
```
Ｊ±⊗Ｌυ⊘⊖Ｌι
```
Jump to the position of the scalar in the output. We can calculate this given that we can keep count of the number of scalars we output and we also know the number of entries in its index list.
```
Ｉ⊟ι
```
Actually print the scalar.
```
Ｗι«
```
Loop over the entries in the index list. Again, this isn't simple iteration, because the entries come in pairs, and we also need to be able to break out of the loop.
```
≔⊟ιζ
```
Extract the next index from the list.
```
¿ζ«
```
If this is not the first element in the list...
```
←§┐┬‹ζ⊟ι
```
... then print `┐` or `┬` depending on whether this is the last element in the list...
```
Ｗ⁼ＫＫψ←─
```
... and print enough `─`s to fill up to the previous entry at this level...
```
≔⁰ι»
```
... and clear the variable to break out of the loop since we're done here.
```
¿⊟ι┌¶┴
```
Otherwise if this is (the first element of) a multiple-element list then print the `┌┴`, leaving the cursor above the `┴` to deal with this level's parent.
```
¦│
```
Otherwise if this is a 1-element list then just print a `│` and move up a line to deal with this level's parent.
]