def _search_status(rdict, doc, status):
    """Includes the relevant entries from `doc` in the resulting `rdict` only
    if the status matches.

    .. warning:: `rdict` is modified by this function.
    """
    if status is None or status == 'issued':
        rdict['issued'] = doc.get('issuance_history')
    if status is None or status == 'revoked':
        rdict['revoked'] = doc.get('revocation_history')
    if status is None or status == 'active':
        rdict['active'] = doc.get('grants')
