$item) { if ($item[$pidField] == $pid) { $child = self::done($items, $item['id'], $pidField); if (count($child)) { $item[$children] = $child; } $tree[] = $item; } } return $tree; } }