basant307/AI_Governance_Project
048
1export default function(end) {2 var start = this,3 ancestor = leastCommonAncestor(start, end),4 nodes = [start];5 while (start !== ancestor) {6 start = start.parent;7 nodes.push(start);8 }9 var k = nodes.length;10 while (end !== ancestor) {11 nodes.splice(k, 0, end);12 end = end.parent;13 }14 return nodes;15}16 17function leastCommonAncestor(a, b) {18 if (a === b) return a;19 var aNodes = a.ancestors(),20 bNodes = b.ancestors(),21 c = null;22 a = aNodes.pop();23 b = bNodes.pop();24 while (a === b) {25 c = a;26 a = aNodes.pop();27 b = bNodes.pop();28 }29 return c;30}31 