Actually, I think the solution here is to change:
#define IDX_GET_NODE_REF(t, x, o) XT_GET_NODE_REF(t, (x) - (o))
to:
#define IDX_GET_NODE_REF(t, x, o) ((o) ? XT_GET_NODE_REF(t, (x) - (o) : 0)
Because if the node reference size (o) is zero, then this particular index node is leaf. And leaves to not have any references to other nodes.
Actually, I think the solution here is to change:
#define IDX_GET_NODE_REF(t, x, o) XT_GET_NODE_REF(t, (x) - (o))
to:
#define IDX_GET_NODE_REF(t, x, o) ((o) ? XT_GET_NODE_REF(t, (x) - (o) : 0)
Because if the node reference size (o) is zero, then this particular index node is leaf. And leaves to not have any references to other nodes.