def METHOD_NAME(identifier: str) -> str:
    """Return DOT edge statement node_id from string, quote if needed.
    >>> quote_edge('spam')
    'spam'
    >>> quote_edge('spam spam:eggs eggs')
    '"spam spam":"eggs eggs"'
    >>> quote_edge('spam:eggs:s')
    'spam:eggs:s'
    """
    node, _, rest = identifier.partition(':')
    parts = [quote(node)]
    if rest:
        port, _, compass = rest.partition(':')
        parts.append(quote(port))
        if compass:
            parts.append(compass)
    return ':'.join(parts)