def dataToComponent(data, component):
    """Converts data to the desired component.

    Parameters
    ----------
    data : `dict`, `object`
        Data from which the component will be constructed. This can be an
        dictionary with keys that are exact match for parameters required
        by component, or a superset, or could be an instance of component
        already.
    component : `cls`
        Class the data will convert to.
    """
    compValue = None
    if isinstance(data, dict):
        try:
            compValue = component(**data)
        except KeyError:
            compValue = component.fromDictSubset(data)
    elif isinstance(data, component):
        compValue = data

    return compValue