Fixed bug for prunning with JS code

Added the case in traverse method for prunning based on an arbitrary Javascript code.
Fixed bug in prune function

It didn't return the self object
Merge pull request #111 from llorentealex/pruning-bugs

Some pruning bugs