public bool CheckValidity(int index, Node[] nodes)
{
if (Checked)
return false;
Checked = true;
return (Parent != 255 || index == nodes.Length - 1) && // Only the root node has no parent.
(Parent > index) && // No self-parenting, parents come from later nodes.
((Left != 0xFF && Right != 0xFF) || (Left == 0xFF && Right == 0xFF)) && // Both branches must be 0xFF if one is.
(Left == 0xFF || (Left < index && nodes[Left].CheckValidity(Left, nodes))) && // Left branch if present is earlier and is also valid.
(Right == 0xFF || (Right < index && nodes[Right].CheckValidity(Right, nodes))) // Right branch if present is earlier and is also valid.
;
}