Not sure if you can simply drop this. The filter will only be useless as long as the TreeWalk has only one tree (i.e. as long you don't go through the code in line 95). So you might want to move this line into the block after line 94.... But I'm not quite sure, as I don't understand your code completely...