def filter_metric_by_category(metrics, category):
    """Returns the metric list filtered by metrics that have the specified category.

    @param metrics: The list of the metrics.
    @param category: The category name, or None if should match for all metrics that have None as category.
    @type metrics: list of MetricDescription
    @type category: str or None
    @return: The filtered list.
    @rtype: list of MetricDescription
    """
    result = []
    for metric in metrics:
        if metric.category is None:
            if category is None:
                result.append(metric)
        elif metric.category == category:
            result.append(metric)
    return result