src/main/java/com/workplacesystems/utilsj/collections/TransactionalBidiTreeMap.java
private Node<K,V> nextSmaller(final Node<K,V> node, final int index) {

        Node<K,V> lval;

        if (node == null) {
            lval = null;
        } else if (node.getLeft(index) != null) {

            // everything to the node's left is smaller. The most of
            // the right node's descendants is the next smaller node
            lval = mostNode(node.getLeft(index), index);
        } else {

            // traverse up our ancestry until we find an ancestor that
            // is null or one whose right child is our ancestor. If we
            // find a null, then this node IS the smallest node in the
            // tree, and there is no smaller node. Otherwise, we are
            // the smallest node in the subtree on that ancestor's right
            // ... and that ancestor is the next smallest node
            Node<K,V> parent = node.getParent(index);
            Node<K,V> child  = node;

            while ((parent != null) && (child == parent.getLeft(index))) {
                child  = parent;
                parent = parent.getParent(index);
            }

            lval = parent;
        }

        return lval;
    }
private Node<K,V> nextSmaller(final Node<K,V> node, final int index) {

        Node<K,V> lval;

        if (node == null) {
            lval = null;
        } else if (node.getLeft(index) != null) {

            // everything to the node's left is smaller. The most of
            // the right node's descendants is the next smaller node
            lval = mostNode(node.getLeft(index), index);
        } else {

            // traverse up our ancestry until we find an ancestor that
            // is null or one whose right child is our ancestor. If we
            // find a null, then this node IS the smallest node in the
            // tree, and there is no smaller node. Otherwise, we are
            // the smallest node in the subtree on that ancestor's right
            // ... and that ancestor is the next smallest node
            Node<K,V> parent = node.getParent(index);
            Node<K,V> child  = node;

            while ((parent != null) && (child == parent.getLeft(index))) {
                child  = parent;
                parent = parent.getParent(index);
            }

            lval = parent;
        }

        return lval;
    }
get the next smaller (previous) node from the specified node

@param node the node to be searched from
@param index KEY or VALUE

@return the specified node