def METHOD_NAME(tp: TestPath) -> str:
    """Create a string representation of TestPath."""
    ret = []
    for component in tp:
        s = ''
        pairs = []
        if component.get('type', None) and component.get('name', None):
            s += _encode_str(component['type']) + '=' + _encode_str(component['name'])
            for k, v in component.items():
                if k not in ('type', 'name'):
                    pairs.append((k, v))
        else:
            for k, v in component.items():
                if not k or not v:
                    continue
                pairs.append((k, v))
            if len(pairs) == 0:
                s = '&'
        pairs = sorted(pairs, key=lambda p: p[0])
        for (k, v) in pairs:
            s += '&'
            s += _encode_str(k) + '=' + _encode_str(v)
        ret.append(s)
    return '#'.join(ret)