def get_csw_records(csw, filter_list, pagesize=10, maxrecords=1000, **kwargs):
    """
    Iterate `maxrecords`/`pagesize` times until the requested value in
    `maxrecords` is reached.

    `kwargs` can by any `getrecords2` key word argument, like esn='full'.

    """
    from owslib.fes import SortBy, SortProperty
    sortby = SortBy([SortProperty('dc:title', 'ASC')])
    csw_records = {}
    startposition = 0
    nextrecord = getattr(csw, 'results', 1)
    while nextrecord != 0:
        csw.getrecords2(constraints=filter_list, startposition=
            startposition, maxrecords=pagesize, sortby=sortby, **kwargs)
        csw_records.update(csw.records)
        if csw.results['nextrecord'] == 0:
            break
        startposition += pagesize + 1
        if startposition >= maxrecords:
            break
    csw.records.update(csw_records)
    return csw
