L idZddlmZmZdZy)z%Generic tools for working with trees.)ceillogch|sgS|dkDsJttt||}|dkr t|Sg}d}||dz z}t dt||D]s}||||z}t||kr|}nYt||kDr8t dt||Dcgc] }||||z }}t||kDr8|j |u|rYt ||}t||t|z kr|j|n|j |t||ksJ|Scc}w)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)rrlenlistrangeappendbuild_n_ary_treeextend) leavesndepthroot unassigned full_stepisubtreeks ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/misc/treeTools.pyr r s@  q5L5 S[!$ %E zF| DJeai I 1c&k9 -Q]+ w<) # J 'lQ38CL!3LMawq1q5)MGM'lQ G":q1 w<1s4y= ( KK KK 4yA~~ KNsD/N)__doc__mathrrr rrs+'r