def _get_single_trace_by_component(**component_filter):
    """
    Tries to return a single Trace mathing component_filter. Raises an exception
    when a filter matches multiple.
    """
    traces = Trace.query(**component_filter)
    if len(traces) == 0:
        return None
    elif len(traces) > 1:
        raise UniqueTraceNotFoundException(
            "More than 1 trace matching %s found." % component_filter
        )
    return traces[0]

    Tries to return a single Trace mathing component_filter. Raises an exception
    when a filter matches multiple.
    
st2common/st2common/services/trace.py