Are there still categories left?
Yes
Is this the lft anchor?
Yes
Is lft anchor == 1 ?
Yes
Valid
Init Variables
No
Invalid!
Add info to corrections array
Init Variables
Is rgt anchor == count(categories) * 2 ?
Yes
Valid
Init Variables
No
Invalid!
Add info to corrections array
Init Variables
No
Is this a rgt single?
Yes
This is a rgt single
Is lft == index + 1 ?
Yes
Valid
No
If empty(stack)
Yes
If empty(unknown_rgt_stack)
Yes
Invalid!
Add info to corrections array
No
Valid
Pop rgt off of unknown_rgt_stack
Add info to corrections array
No
If end(stack) == index + 1
Yes
Valid
Pop rgt off of stack
No
Invalid!
Add info to corrections array
Pop rgt off of stack
Is rgt == index + 2 ?
Yes
Valid
index += 2
No
Invalid!
Add info to corrections array
index += 2
No
This is a rgt parent
while index < lft
Is lft == index + 1 ?
Yes
Is rgt < index + 5 ?
Yes
Invalid!
Push rgt onto unknown_rgt_stack
index++
No
Valid
Push rgt onto stack
index++
No
If empty(stack)
Yes
Invalid!
Add info to corrections array
lft = index + 1
Is this a rgt single?
Yes
This is a rgt single
Is lft == index + 1 ?
Yes
Valid
No
If empty(stack)
Yes
If empty(unknown_rgt_stack)
Yes
Invalid!
Add info to corrections array
No
Valid
Pop rgt off of unknown_rgt_stack
Add info to corrections array
No
If end(stack) == index + 1
Yes
Valid
Pop rgt off of stack
No
Invalid!
Add info to corrections array
Pop rgt off of stack
Is rgt == index + 2 ?
Yes
Valid
index += 2
No
Invalid!
Add info to corrections array
index += 2
No
This is a rgt parent
while index < lft
Is lft == index + 1 ?
Yes
Is rgt < index + 5 ?
Yes
Invalid!
Push rgt onto unknown_rgt_stack
index++
No
Valid
Push rgt onto stack
index++
No
If empty(stack)
Yes
Invalid!
Add info to corrections array
lft = index + 1
No
If end(stack) == index + 1
Yes
Valid
Pop rgt off of stack
index++
No
If empty(unknown_rgt_stack)
Yes
Invalid!
Add info to corrections array
index++
No
Valid
Pop rgt off of unknown_rgt_stack
Add info to corrections array
index++
No
If end(stack) == index + 1
Yes
Valid
Pop rgt off of stack
index++
No
If empty(unknown_rgt_stack)
Yes
Invalid!
Add info to corrections array
index++
No
Valid
Pop rgt off of unknown_rgt_stack
Add info to corrections array
index++
No
While index < end
Is index == end - 1 ?
Yes
End!
No
If empty(stack)
Yes
Invalid!
Add info to corrections array
index++
No
If end(stack) == index + 1
Yes
Valid
Pop rgt off of stack
index++
No
Invalid!
Add info to corrections array
Pop rgt off of stack
index++