function pathToAncestor(node, ancestor) {
			const path = [node];
			let currentNode = node;

			while (currentNode !== ancestor) {
				currentNode = currentNode.parent;

				/* c8 ignore start */
				if (currentNode === null) {
					throw new Error(
						"Nodes are not in the ancestor-descendant relationship.",
					);
				} /* c8 ignore stop */

				path.push(currentNode);
			}

			return path;
		}
Finds the path from the given node to the specified ancestor.
@param {ASTNode} node First node in the path.
@param {ASTNode} ancestor Last node in the path.
@returns {ASTNode[]} Path, including both nodes.
@throws {Error} If the given node does not have the specified ancestor.