private static int GetNestedDepthOfTable(Table table)
{
int depth = 0;
NodeType type = table.NodeType;
// The parent of the table will be a Cell, instead attempt to find a grandparent that is of type Table
Node parent = table.GetAncestor(type);
while (parent != null)
{
// Every time we find a table a level up we increase the depth counter and then try to find an
// ancestor of type table from the parent.
depth++;
parent = parent.GetAncestor(type);
}
return depth;
}