Absolute paths are needed only if you do not know the full path, and is not a common situation.
For a node/script to access a grandchild, you can use relative paths, like $child_node/grandchild_node
($ is the same to get_node).
To get a sibling, you can do, from child_node1 get_parent().get_node(child_node2)
or $"../child_node2"
(relative, starts in node 1, goes up, gets node 2).
The ..
refers to the parent, the notation is the same used on text consoles (cmd, bash) when changing directories or reading/opening files.
You can even do get_node
or $
with "../.."
to get a grandparent instead of get_parent().get_parent()
.
For a single scene you can do export(NodePath) var foo_path
and use the inspector to pick a node from the tree, so you do not have to worry about the path, then in the script get the node reference with get_node(foo_path)
.
It is always advised to avoid accessing other than down the tree from a particular node and the parent at most when going up, because that may imply a problem in the design that later will be reflected in entangled scenes and code that will be difficult to maintain and fix.