level -= 1 if level > 0
moved level modification outside of nested function
Merge pull request #83 from wasade/cat_level_indexing

level -= 1 if level > 0