Created a tree::node_cast operation as casting was getting messy.

Added lots of extra checks into the operations to ensure that
identifiers are not treated as expressions.