Note

The wasBinarySearchTreeSuccessor function takes as arguments:

and returns the in-order successor of the specified node in the binary search tree.

Code

This script was tested and works on OpenSim version 0.7.5!

///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasBinarySearchTreeSuccessor(list BST, string node) {
    string right = wasBinaryTreeRight(BST, node);
    if(right != "") return wasBinarySearchTreeMinimum(BST, right);
    string parent = wasBinaryTreeParent(BST, node);
    while(parent != "" && node == wasBinaryTreeRight(BST, parent)) {
        node = wasBinaryTreeParent(BST, node);
        parent = wasBinaryTreeParent(BST, parent);
    }
    return parent;
}