Added possibility to compare trees for equality

Trees being lists, this patch adds an ```__eq__``` to terminals and primitives. For terminals, we compare the value and return type, while for primitives the name, the arguments and the return type.