1. Are there still categories left?
    1. Yes
      1. Is this the lft anchor?
        1. Yes
          1. Is lft anchor == 1 ?
          2. Yes
          3. Valid
          4. Init Variables
          5. No
          6. Invalid!
          7. Add info to corrections array
          8. Init Variables
          9. Is rgt anchor == count(categories) * 2 ?
          10. Yes
          11. Valid
          12. Init Variables
          13. No
          14. Invalid!
          15. Add info to corrections array
          16. Init Variables
        2. No
          1. Is this a rgt single?
          2. Yes
          3. This is a rgt single
          4. Is lft == index + 1 ?
          5. Yes
          6. Valid
          7. No
          8. If empty(stack)
          9. Yes
          10. If empty(unknown_rgt_stack)
          11. Yes
          12. Invalid!
          13. Add info to corrections array
          14. No
          15. Valid
          16. Pop rgt off of unknown_rgt_stack
          17. Add info to corrections array
          18. No
          19. If end(stack) == index + 1
          20. Yes
          21. Valid
          22. Pop rgt off of stack
          23. No
          24. Invalid!
          25. Add info to corrections array
          26. Pop rgt off of stack
          27. Is rgt == index + 2 ?
          28. Yes
          29. Valid
          30. index += 2
          31. No
          32. Invalid!
          33. Add info to corrections array
          34. index += 2
          35. No
          36. This is a rgt parent
          37. while index < lft
          38. Is lft == index + 1 ?
          39. Yes
          40. Is rgt < index + 5 ?
          41. Yes
          42. Invalid!
          43. Push rgt onto unknown_rgt_stack
          44. index++
          45. No
          46. Valid
          47. Push rgt onto stack
          48. index++
          49. No
          50. If empty(stack)
          51. Yes
          52. Invalid!
          53. Add info to corrections array
          54. lft = index + 1
          55. Is this a rgt single?
          56. Yes
          57. This is a rgt single
          58. Is lft == index + 1 ?
          59. Yes
          60. Valid
          61. No
          62. If empty(stack)
          63. Yes
          64. If empty(unknown_rgt_stack)
          65. Yes
          66. Invalid!
          67. Add info to corrections array
          68. No
          69. Valid
          70. Pop rgt off of unknown_rgt_stack
          71. Add info to corrections array
          72. No
          73. If end(stack) == index + 1
          74. Yes
          75. Valid
          76. Pop rgt off of stack
          77. No
          78. Invalid!
          79. Add info to corrections array
          80. Pop rgt off of stack
          81. Is rgt == index + 2 ?
          82. Yes
          83. Valid
          84. index += 2
          85. No
          86. Invalid!
          87. Add info to corrections array
          88. index += 2
          89. No
          90. This is a rgt parent
          91. while index < lft
          92. Is lft == index + 1 ?
          93. Yes
          94. Is rgt < index + 5 ?
          95. Yes
          96. Invalid!
          97. Push rgt onto unknown_rgt_stack
          98. index++
          99. No
          100. Valid
          101. Push rgt onto stack
          102. index++
          103. No
          104. If empty(stack)
          105. Yes
          106. Invalid!
          107. Add info to corrections array
          108. lft = index + 1
          109. No
          110. If end(stack) == index + 1
          111. Yes
          112. Valid
          113. Pop rgt off of stack
          114. index++
          115. No
          116. If empty(unknown_rgt_stack)
          117. Yes
          118. Invalid!
          119. Add info to corrections array
          120. index++
          121. No
          122. Valid
          123. Pop rgt off of unknown_rgt_stack
          124. Add info to corrections array
          125. index++
          126. No
          127. If end(stack) == index + 1
          128. Yes
          129. Valid
          130. Pop rgt off of stack
          131. index++
          132. No
          133. If empty(unknown_rgt_stack)
          134. Yes
          135. Invalid!
          136. Add info to corrections array
          137. index++
          138. No
          139. Valid
          140. Pop rgt off of unknown_rgt_stack
          141. Add info to corrections array
          142. index++
    2. No
      1. While index < end
        1. Is index == end - 1 ?
          1. Yes
          2. End!
          3. No
          4. If empty(stack)
          5. Yes
          6. Invalid!
          7. Add info to corrections array
          8. index++
          9. No
          10. If end(stack) == index + 1
          11. Yes
          12. Valid
          13. Pop rgt off of stack
          14. index++
          15. No
          16. Invalid!
          17. Add info to corrections array
          18. Pop rgt off of stack
          19. index++