internal static DecisionNode GetNextSibling(Dictionary<DecisionNode, int> cursors, DecisionNode node)
{
var parent = node.Parent;
if (parent == null) return null;
// Get current node index
int index;
if (!cursors.TryGetValue(node, out index))
cursors[node] = index = 0;
int nextIndex = index + 1;
if (nextIndex < parent.Branches.Count)
{
var sibling = parent.Branches[nextIndex];
cursors[sibling] = nextIndex;
return sibling;
}
return null;
}