def find_field_in_modified_field(field):
    """
    Returns the field from a modified field argument (or just the field argument if it is not modified). A modified
    field represents either a wrapped dimension (e.g. DatetimeInterval) or a field wrapped in a filter.
    """
    modified_field = field
    while hasattr(modified_field, "dimension"):
        modified_field = modified_field.dimension
    while hasattr(modified_field, "field"):
        modified_field = modified_field.field
    return modified_field