Explain how you would refactor a legacy component to improve its maintainability and performance.
For this coding exercise, represent the component as a nested dictionary and return visible component IDs in preorder. Invisible components and their entire subtrees must be skipped; preserve the original child order.
Signature: visible_component_ids(component)
The input contains id, visible, and optional children fields. Return a list of visible IDs.
def visible_component_ids(component):