<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_headers(self, headers):
 """Generate a SpanContext object using the W3C Distributed Tracing headers. :type headers: dict :param headers: HTTP request headers. :rtype: :class:`~opencensus.trace.span_context.SpanContext` :returns: SpanContext generated from the trace context header. """

        if headers is None:
            return SpanContext()

        header = headers.get(_TRACEPARENT_HEADER_NAME)
        if header is None:
            return SpanContext()

        match = re.search(_TRACEPARENT_HEADER_FORMAT_RE, header)
        if not match:
            return SpanContext()

        version = match.group(1)
        trace_id = match.group(2)
        span_id = match.group(3)
        trace_options = match.group(4)

        if trace_id == '0' * 32 or span_id == '0' * 16:
            return SpanContext()

        if version == '00':
            if match.group(5):
                return SpanContext()
        if version == 'ff':
            return SpanContext()

        span_context = SpanContext(
            trace_id=trace_id,
            span_id=span_id,
            trace_options=TraceOptions(trace_options),
            from_header=True)

        header = headers.get(_TRACESTATE_HEADER_NAME)
        if header is None:
            return span_context
        try:
            tracestate = TracestateStringFormatter().from_string(header)
            if tracestate.is_valid():
                span_context.tracestate = \
                    TracestateStringFormatter().from_string(header)
        except ValueError:
            pass
        return span_context