> have a very confusing relationship to the coordinates
Agreed. I sometimes get confused too.
One rule that always holds is this:
1) One line === One node
So every node has an absolute Y coordinate (just the line number), but also a relative coordinate(s), relative to its ancestor(s).
Both are useful at various times. There's probably a better way to eliminate confusion here.
> So the coordinates do not actually define the relationships between nodes
Given an array of node coordinates {y,x} [{1,1}, {2,2}, {3,1}, {4,2}], one has enough information to define the whole tree structure of the program. But you are right, you need the full set of coordinates of a certain node's ancestors to properly know its coordinates, and having a line that begins with 1 or more spaces, it is impossible to deduce how many nodes deep it is without also having access to the previous line(s).