a
    w=ic                     @   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r6t| S g }d} |d  }tdt| |D ]`}| |||  t|k r} qt kr fddtdt D q| qZ|rt| t t| 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                    s   g | ]}||   qS  r   ).0knsubtreer   i/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/fontTools/misc/treeTools.py
<listcomp>        z$build_n_ary_tree.<locals>.<listcomp>)r   r   lenlistrangeappendbuild_n_ary_treeextend)leavesr	   depthrootZ
unassignedZ	full_stepir   r   r   r      s0    "

r   N)__doc__mathr   r   r   r   r   r   r   <module>   s   