code: public TreeGraphNode highestNodeWithSameHead() {
      TreeGraphNode node = this;
      while (true) {
        TreeGraphNode parent = safeCast(node.parent());
        if (parent == null || parent.headWordNode() != node.headWordNode()) {
          return node;
        }
        node = parent;
      }
    }
docs: Checks the node's ancestors to find the highest ancestor with the
  same <code>headWordNode</code> as this node.