�
��g� � � � d Z ddlmZmZ d� ZdS )z%Generic tools for working with trees.� )�ceil�logc �� ��� | sg S �dk sJ �t t t | � � �� � � � }|dk rt | � � S g }d}�|dz
z }t dt | � � |� � D ]�}| |||z � �t �� � |k r�} ngt �� � �k r>��fd�t dt �� � �� � D � � �t �� � �k �>|� �� � ��|rst
|�� � �t �� � �t |� � z
k r|� �� � n|� �� � t |� � �k sJ �|S )z�Build 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 ���h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fontTools/misc/treeTools.py�
<listcomp>z$build_n_ary_tree.<locals>.<listcomp> s&