You can use ".." to traverse through the ancestors.
If you have a hierarchy like this
world
boat
gun
If you call get_node("../../")
from the gun, you will get the world node.
Additionally, you can do in script
export(NodePath) var parent_path
and then you can browse and choose required node from the editor itself. Later if you change the hierarchy, you just need to select the path in the editor and don't require to edit the script.