I found a piece of code and algorithm that makes it possible to collaborate online on tree structures. I have been using Logseq for the last few months and this algorithm seems to be a way to make collaboration on an outliner possible.
Evan Wallace described this algorithm. The page also includes a demo application. I have rewritten this demo application to Go and implemented a network protocol with mangos. Mangos is a nanomsg port in Go. Mangos can use websockets. This makes it possible to use a Go backend server with nanomsg protocols to send the changes from other clients back and forth between the clients. My implementation is just a prototype.
The Go implementation that I wrote is used for command-line clients that build a tree. The changes of the clients are sent to the server and the other clients. The server does not inspect the contents of the message, it just re-transmits it to the next client.
The changes in the browser are also sent back to the server, which makes this all for exciting. This is a nice first step into building an outliner with collaboration and block or line based sync, instead of full page sync.