Slightly tweaked TreeLopper.