o
    h                     @   s    d Z ddlmZmZ dd ZdS )z%Generic tools for working with trees.    )ceillogc                    s  | sg S  dks
J t tt|  }|dkrt| S g }d} |d  }tdt| |D ]5}| |||  t|k rA} n"t kr] fddtdt D t ksG| q-|rt| t t| krz| n| t| ksJ |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                    s   g | ]
}||   qS  r   ).0knsubtreer   l/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fontTools/misc/treeTools.py
<listcomp>    s    z$build_n_ary_tree.<locals>.<listcomp>)r   r   lenlistrangeappendbuild_n_ary_treeextend)leavesr	   depthroot
unassigned	full_stepir   r   r   r      s2    

r   N)__doc__mathr   r   r   r   r   r   r   <module>   s    