
    ]Mh                          d Z ddlmZmZ d ZdS )z%Generic tools for working with trees.    )ceillogc                    | sg S dk    sJ t          t          t          |                               }|dk    rt          |           S g }d}|dz
  z  }t	          dt          |           |          D ]}| |||z            t                    |k     r} ngt                    k    r>fdt	          dt                              D             t                    k    >|                               |rst          |          t                    t          |          z
  k    r|                               n|                               t          |          k    sJ |S )zBuild N-ary tree from sequence of leaf nodes.

    Return a list of lists where each non-leaf node is a list containing
    max n nodes.
       Nr   c                 *    g | ]}||z            S  r   ).0knsubtrees     X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/fontTools/misc/treeTools.py
<listcomp>z$build_n_ary_tree.<locals>.<listcomp>    s&    MMMawq1q5y)MMM    )r   r   lenlistrangeappendbuild_n_ary_treeextend)leavesr   depthroot
unassigned	full_stepir   s    `     @r   r   r      s     	q5555S[[!$$%%EzzF|| DJeai I1c&kk9--  Q]*+w<<)## JE'llQMMMMM5CLL!3L3LMMMG 'llQG ":q11w<<1s4yy=((KK    KK   4yyA~~~~Kr   N)__doc__mathr   r   r   r   r   r   <module>r      s<    + +        ' ' ' ' 'r   