Index: src/AST/Node.cpp
===================================================================
--- src/AST/Node.cpp	(revision e0e9a0be9170b7c4033834533d5ce2734166eb97)
+++ src/AST/Node.cpp	(revision 7d0881c5d24fef8ba66a626f072330c3ad5d9d76)
@@ -50,7 +50,7 @@
 
 template< typename node_t, enum ast::Node::ref_type ref_t >
-void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node ) {
+void ast::ptr_base<node_t, ref_t>::_dec( const node_t * node, bool do_delete ) {
 	_trap( node );
-	node->decrement(ref_t);
+	node->decrement(ref_t, do_delete );
 }
 
Index: src/AST/Node.hpp
===================================================================
--- src/AST/Node.hpp	(revision e0e9a0be9170b7c4033834533d5ce2734166eb97)
+++ src/AST/Node.hpp	(revision 7d0881c5d24fef8ba66a626f072330c3ad5d9d76)
@@ -69,5 +69,5 @@
 	}
 
-	void decrement(ast::Node::ref_type ref) const {
+	void decrement(ast::Node::ref_type ref, bool do_delete = true) const {
 		switch (ref) {
 			case ref_type::strong: strong_count--; break;
@@ -75,5 +75,5 @@
 		}
 
-		if(!strong_count && !weak_count) {
+		if( do_delete && !strong_count && !weak_count) {
 			delete this;
 		}
@@ -228,4 +228,13 @@
 	operator const node_t * () const { _check(); return node; }
 
+	const node_t * release() {
+		const node_t * ret = node;
+		if ( node ) {
+			_dec(node, false);
+			node = nullptr;
+		}
+		return ret;
+	}
+
 	/// wrapper for convenient access to dynamic_cast
 	template<typename o_node_t>
@@ -253,5 +262,5 @@
 
 	void _inc( const node_t * other );
-	void _dec( const node_t * other );
+	void _dec( const node_t * other, bool do_delete = true );
 	void _check() const;
 
