Are there still categories left?
Yes
Is this the lft anchor?
Yes
If lft anchor == 1
Yes
Valid
Init Variables
No
Invalid!
Add info to corrections array
Init Variables
If rgt anchor == count(categories) * 2
Yes
Valid
Init Variables
No
Invalid!
Add info to corrections array
Init Variables
No
Is this a child node?
Yes
This is a child
If index >= lft
Yes
Invalid!
lft = index + 1
rgt = index + 2
No
while index < lft
If lft == index + 1
Yes
If rgt == index + 2
Yes
Valid
index += 2
No
Invalid!
Add info to corrections array
index += 2
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
Invalid!
Add info to corrections array
lft = index + 1
No
This is a parent
If index >= lft
Yes
Invalid!
lft = index + 1
No
while index < lft
If lft == index + 1
Yes
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
Invalid!
Add info to corrections array
lft = index + 1
No
While index < end
If 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!
Pop rgt off of stack
Add info to corrections array
index++