Only call action_insert_node if the node type is an element or text

This would resolve the `local variable 'node' referenced before assignment` error.