// =================================================================== /// Return the first shared parent between two visual script objects. /// /// @param vsObj1 The first visual script object. /// @param vsObj2 The second visual script object. /// @return The first shared parent. /// public static iCS_EditorObject GetCommonParent(iCS_EditorObject vsObj1, iCS_EditorObject vsObj2) { if (vsObj1 == null) { return(vsObj2); } if (vsObj2 == null) { return(vsObj1); } var l1 = BuildListOfParentNodes(vsObj1); var l2 = BuildListOfParentNodes(vsObj2); l1 = P.insertAt(vsObj1, l1.Length, l1); l2 = P.insertAt(vsObj2, l2.Length, l2); iCS_EditorObject commonParent = null; for (int i = 0; i < l1.Length && i < l2.Length; ++i) { if (l1[i] != l2[i]) { break; } commonParent = l1[i]; } return(commonParent); }