Statement
Write buildTree(categories). You get flat categories { id, parentId, name } (parentId is null for roots), like an online shop's. Return the roots with their children nested in children, sorted by name at every level. Categories whose parent doesn't exist are ignored.