# File lib/scrubyt/utils/xpathutils.rb, line 10 def self.lowest_common_ancestor(node1, node2) path1 = traverse_up(node1) path2 = traverse_up(node2) return node1.parent if path1 == path2 closure = nil while (!path1.empty? && !path2.empty?) closure = path1.pop return closure.parent if (closure != path2.pop) end path1.size > path2.size ? path1.last.parent : path2.last.parent end