<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse(cls, addr):
 """Parses a new `Uri` instance from a string representation of a URI. (None, ['', 'foo', 'bar'], '/foo/bar', 'bar') ('somenode:123', ['', 'foo', 'bar'], '/foo/bar', 'bar') (None, ['foo', 'bar'], 'foo/bar', 'bar') """

        if addr.endswith('/'):
            raise ValueError("Uris must not end in '/'")  # pragma: no cover
        parts = addr.split('/')
        if ':' in parts[0]:
            node, parts[0] = parts[0], ''
        else:
            node = None

        ret = None  # Uri(name=None, parent=None, node=node) if node else None
        for step in parts:
            ret = Uri(name=step, parent=ret, node=node)
            node = None  # only set the node on the root Uri
        return ret