Given a specific UI requirement, how would you structure the component hierarchy?
Implement build_component_hierarchy(components) to represent the hierarchy as nested component nodes. Each input component has an id, name, and optional parentId; return root components in input order, with descendants stored in a children array. Preserve the input order among siblings. The input contains valid unique IDs and no cycles.
def build_component_hierarchy(components):