def METHOD_NAME(data):
    """Construct correct locator subclass from dictionary,
    which should contain a 'type' field and at least all
    required fields of that locator.
    """
    type_ = data.pop("type", None)
    if not type_:
        raise ValueError("Missing locator type field")
    class_ = TYPES.get(type_)
    if not class_:
        raise ValueError(f"Unknown locator type: {type_}")
    # Check for missing parameters
    required = set(
        field.name for field in fields(class_) if field.default is MISSING
    )
    missing = set(required) - set(data)
    if missing:
        raise ValueError("Missing locator field(s): {}".format(", ".join(missing)))
    # Ignore extra data
    required_or_optional = [field.name for field in fields(class_)]
    kwargs = {k: v for k, v in data.items() if k in required_or_optional}
    return class_(**kwargs)