fix a typo.
convert to Python3.
remove redundant conjunct in the check (not needed after token is a sub-class of
node)
"next" is a reservedidentifier avoid it.