def METHOD_NAME(self, node: "Node", prev: Optional[int] = None) -> int:
    """Attach node to another."""
    if prev is not None and prev not in self.chain:
        raise ChainException("Unknown predecessor: " + str(prev))
    else:
        id = self._get_id()
        node.set_id(id)
        node.set_prev(prev)
        if prev is not None:
            self.chain[prev].add_succ(id)
        self.chain[id] = node
    return id