diff --git a/alib2data/src/tree/TreeBase.h b/alib2data/src/tree/TreeBase.h
deleted file mode 100644
index 75a7bb07330aecba7c173ac218ef8d8958c4150e..0000000000000000000000000000000000000000
--- a/alib2data/src/tree/TreeBase.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * TreeBase.h
- *
- * This file is part of Algorithms library toolkit.
- * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
-
- * Algorithms library toolkit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * Algorithms library toolkit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  Created on: Nov 16, 2014
- *      Author: Stepan Plachy
- */
-
-#ifndef TREE_BASE_H_
-#define TREE_BASE_H_
-
-#include <alib/compare>
-
-namespace tree {
-
-/**
- * \brief Represents base for a concrete tree type.
- */
-class TreeBase : public ext::CompareOperators < TreeBase > {
-public:
-	virtual ~TreeBase ( ) noexcept {
-	}
-
-	/**
-	 * \brief Comparison helper method evaluating allowing possibly deeper comparison of this with other class of the same type.
-	 *
-	 * \details If the other class is of different type the relative order is computer by means of type_index.
-	 *
-	 * \param other the other class to compare with
-	 *
-	 * \returns result of actual comparison if type of this class and other class is the same, result of difference of type indexes othervise.
-	 */
-	virtual int compare ( const TreeBase & other ) const = 0;
-
-	friend std::ostream & operator << ( std::ostream & os, const TreeBase & instance ) {
-		instance >> os;
-		return os;
-	}
-
-	virtual void operator >> ( std::ostream & os ) const = 0;
-
-	virtual operator std::string ( ) const = 0;
-};
-
-} /* namespace tree */
-
-#endif /* TREE_BASE_H_ */
diff --git a/alib2data/src/tree/ranked/PostfixRankedTree.h b/alib2data/src/tree/ranked/PostfixRankedTree.h
index 0bf2afd43970320d7ca15933addc772c95ea7f7e..8e3da730c8bb547b9fe48be41e991eb8822988b1 100644
--- a/alib2data/src/tree/ranked/PostfixRankedTree.h
+++ b/alib2data/src/tree/ranked/PostfixRankedTree.h
@@ -34,18 +34,19 @@ class PostfixRankedTree;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <core/normalize.hpp>
@@ -72,7 +73,7 @@ class GeneralAlphabet;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PostfixRankedTree final : public TreeBase, public core::Components < PostfixRankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
+class PostfixRankedTree final : public ext::CompareOperators < PostfixRankedTree < SymbolType, RankType > >, public core::Components < PostfixRankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
 	/**
 	 * Linear representation of the tree content.
 	 */
@@ -163,15 +164,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -182,14 +174,27 @@ public:
 	int compare ( const PostfixRankedTree & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PostfixRankedTree & instance ) {
+		out << "(PostfixRankedTree ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -265,16 +270,6 @@ int PostfixRankedTree < SymbolType, RankType >::compare ( const PostfixRankedTre
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PostfixRankedTree < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PostfixRankedTree ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PostfixRankedTree < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h
index 00dd961d7fc1e824b0a57b1eb8fefe401fd0e61f..a363d2e72464ad7445393a74274ff2868dab3d4f 100644
--- a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h
+++ b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h
@@ -34,10 +34,11 @@ class PrefixRankedBarNonlinearPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
 
@@ -45,7 +46,6 @@ class PrefixRankedBarNonlinearPattern;
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <alphabet/BarSymbol.h>
@@ -90,7 +90,7 @@ class NonlinearAlphabet;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PrefixRankedBarNonlinearPattern final : public TreeBase, public core::Components < PrefixRankedBarNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > {
+class PrefixRankedBarNonlinearPattern final : public ext::CompareOperators < PrefixRankedBarNonlinearPattern < SymbolType, RankType > >, public core::Components < PrefixRankedBarNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > {
 	/**
 	 * Linear representation of the pattern content.
 	 */
@@ -335,15 +335,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -354,14 +345,31 @@ public:
 	int compare ( const PrefixRankedBarNonlinearPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixRankedBarNonlinearPattern & instance ) {
+		out << "(PrefixRankedBarNonlinearPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "bars = " << instance.getBars ( );
+		out << "variablesBar = " << instance.getVariablesBar ( );
+		out << "content = " << instance.getContent ( );
+		out << "nonlinearVariables = " << instance.getNonlinearVariables ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -487,16 +495,6 @@ int PrefixRankedBarNonlinearPattern < SymbolType, RankType >::compare ( const Pr
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PrefixRankedBarNonlinearPattern < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixRankedBarNonlinearPattern ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PrefixRankedBarNonlinearPattern < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h
index 93f2b5ee99a53eb07ef7150a7a83cb3cdae4ef5d..c1818cd1de536800313352b7b7b004e2d5a7c46c 100644
--- a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h
+++ b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h
@@ -34,18 +34,19 @@ class PrefixRankedBarPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <alphabet/BarSymbol.h>
@@ -85,7 +86,7 @@ class VariablesBarSymbol;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PrefixRankedBarPattern final : public TreeBase, public core::Components < PrefixRankedBarPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > {
+class PrefixRankedBarPattern final : public ext::CompareOperators < PrefixRankedBarPattern < SymbolType, RankType > >, public core::Components < PrefixRankedBarPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols >, common::ranked_symbol < SymbolType, RankType >, component::Value, std::tuple < SubtreeWildcard, VariablesBarSymbol > > {
 	/**
 	 * Linear representation of the pattern content.
 	 */
@@ -261,15 +262,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -280,14 +272,30 @@ public:
 	int compare ( const PrefixRankedBarPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixRankedBarPattern & instance ) {
+		out << "(PrefixRankedBarPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "bars = " << instance.getBars ( );
+		out << "variablesBar = " << instance.getVariablesBar ( );
+		out << "content = " << instance.getContent ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -385,16 +393,6 @@ int PrefixRankedBarPattern < SymbolType, RankType >::compare ( const PrefixRanke
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PrefixRankedBarPattern < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixRankedBarPattern ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PrefixRankedBarPattern < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/PrefixRankedBarTree.h b/alib2data/src/tree/ranked/PrefixRankedBarTree.h
index bca35883f5ffc94f47ff4ada9ea17fd30ec253c7..592190f62691261d50fbf239d7fc645dc458b19e 100644
--- a/alib2data/src/tree/ranked/PrefixRankedBarTree.h
+++ b/alib2data/src/tree/ranked/PrefixRankedBarTree.h
@@ -34,18 +34,19 @@ class PrefixRankedBarTree;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <alphabet/BarSymbol.h>
@@ -78,7 +79,7 @@ class BarSymbols;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PrefixRankedBarTree final : public TreeBase, public core::Components < PrefixRankedBarTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols > > {
+class PrefixRankedBarTree final : public ext::CompareOperators < PrefixRankedBarTree < SymbolType, RankType > >, public core::Components < PrefixRankedBarTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, BarSymbols > > {
 	/**
 	 * Linear representation of the tree content.
 	 */
@@ -206,15 +207,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -225,14 +217,28 @@ public:
 	int compare ( const PrefixRankedBarTree & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixRankedBarTree & instance ) {
+		out << "(PrefixRankedBarTree ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "bars = " << instance.getBars ( );
+		out << "content = " << instance.getContent ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -321,16 +327,6 @@ int PrefixRankedBarTree < SymbolType, RankType >::compare ( const PrefixRankedBa
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PrefixRankedBarTree < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixRankedBarTree ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PrefixRankedBarTree < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h
index 55dc659ab6c1f5da9ce495f98f2ed4a823e432db..c53a54fd1ebb4b3c3ef5ea373c384061eaf2c291 100644
--- a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h
+++ b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h
@@ -34,18 +34,19 @@ class PrefixRankedNonlinearPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <alphabet/WildcardSymbol.h>
@@ -82,7 +83,7 @@ class NonlinearAlphabet;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PrefixRankedNonlinearPattern final : public TreeBase, public core::Components < PrefixRankedNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
+class PrefixRankedNonlinearPattern final : public ext::CompareOperators < PrefixRankedNonlinearPattern < SymbolType, RankType > >, public core::Components < PrefixRankedNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
 	/**
 	 * Linear representation of the pattern content.
 	 */
@@ -249,15 +250,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -268,14 +260,29 @@ public:
 	int compare ( const PrefixRankedNonlinearPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixRankedNonlinearPattern & instance ) {
+		out << "(PrefixRankedNonlinearPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << "nonlinearVariables = " << instance.getNonlinearVariables ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -371,16 +378,6 @@ int PrefixRankedNonlinearPattern < SymbolType, RankType >::compare ( const Prefi
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PrefixRankedNonlinearPattern < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixRankedNonlinearPattern ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PrefixRankedNonlinearPattern < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/PrefixRankedPattern.h b/alib2data/src/tree/ranked/PrefixRankedPattern.h
index 839d1ddfb690b5c46ea95901fed635ab60945dcb..e6937ecc4888e7bf890752017187d8d4f620e23d 100644
--- a/alib2data/src/tree/ranked/PrefixRankedPattern.h
+++ b/alib2data/src/tree/ranked/PrefixRankedPattern.h
@@ -34,18 +34,19 @@ class PrefixRankedPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <alphabet/WildcardSymbol.h>
@@ -77,7 +78,7 @@ class SubtreeWildcard;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PrefixRankedPattern final : public TreeBase, public core::Components < PrefixRankedPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
+class PrefixRankedPattern final : public ext::CompareOperators < PrefixRankedPattern < SymbolType, RankType > >, public core::Components < PrefixRankedPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
 	/**
 	 * Linear representation of the pattern content.
 	 */
@@ -195,15 +196,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -214,14 +206,28 @@ public:
 	int compare ( const PrefixRankedPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixRankedPattern & instance ) {
+		out << "(PrefixRankedPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -301,16 +307,6 @@ int PrefixRankedPattern < SymbolType, RankType >::compare ( const PrefixRankedPa
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PrefixRankedPattern < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixRankedPattern ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PrefixRankedPattern < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/PrefixRankedTree.h b/alib2data/src/tree/ranked/PrefixRankedTree.h
index 9502357bdc40a5fa4de51e021509f5d570e237c9..5eac58d01a0f639f3fd3dbd800393870568f2149 100644
--- a/alib2data/src/tree/ranked/PrefixRankedTree.h
+++ b/alib2data/src/tree/ranked/PrefixRankedTree.h
@@ -34,18 +34,19 @@ class PrefixRankedTree;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/set>
 #include <alib/vector>
 #include <alib/tree>
-#include <sstream>
 #include <alib/algorithm>
 #include <alib/deque>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 
 #include <core/normalize.hpp>
 #include <tree/common/TreeNormalize.h>
@@ -71,7 +72,7 @@ class GeneralAlphabet;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class PrefixRankedTree final : public TreeBase, public core::Components < PrefixRankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
+class PrefixRankedTree final : public ext::CompareOperators < PrefixRankedTree < SymbolType, RankType > >, public core::Components < PrefixRankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
 	/**
 	 * Linear representation of the tree content.
 	 */
@@ -169,15 +170,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -188,14 +180,27 @@ public:
 	int compare ( const PrefixRankedTree & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixRankedTree & instance ) {
+		out << "(PrefixRankedTree ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -275,16 +280,6 @@ int PrefixRankedTree < SymbolType, RankType >::compare ( const PrefixRankedTree
 	return comp ( first, second );
 }
 
-template < class SymbolType, class RankType >
-void PrefixRankedTree < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixRankedTree ";
-
-	for ( const common::ranked_symbol < SymbolType, RankType > & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType, class RankType >
 PrefixRankedTree < SymbolType, RankType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/ranked/RankedNonlinearPattern.h b/alib2data/src/tree/ranked/RankedNonlinearPattern.h
index a0eebd031737d51fbf75a63aacbf6c72f16dbc87..fb96f9944a8c38b50a11220589efd2dcf9c5cb30 100644
--- a/alib2data/src/tree/ranked/RankedNonlinearPattern.h
+++ b/alib2data/src/tree/ranked/RankedNonlinearPattern.h
@@ -34,18 +34,18 @@ class RankedNonlinearPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/string>
 #include <alib/set>
 #include <alib/tree>
 #include <alib/iostream>
 #include <alib/algorithm>
-#include <sstream>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <core/normalize.hpp>
@@ -74,7 +74,7 @@ class NonlinearAlphabet;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class RankedNonlinearPattern final : public TreeBase, public core::Components < RankedNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
+class RankedNonlinearPattern final : public ext::CompareOperators < RankedNonlinearPattern < SymbolType, RankType > >, public core::Components < RankedNonlinearPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
 	/**
 	 * Natural representation of the pattern content.
 	 */
@@ -219,15 +219,6 @@ public:
 	 */
 	void setTree ( ext::tree < common::ranked_symbol < SymbolType, RankType > > pattern );
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -238,14 +229,29 @@ public:
 	int compare ( const RankedNonlinearPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const RankedNonlinearPattern & instance ) {
+		out << "(RankedNonlinearPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << "nonlinearVariables = " << instance.getNonlinearVariables ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * Nice printer of the tree natural representation
@@ -310,11 +316,6 @@ void RankedNonlinearPattern < SymbolType, RankType >::setTree ( ext::tree < comm
 	this->m_content = std::move ( pattern );
 }
 
-template < class SymbolType, class RankType >
-void RankedNonlinearPattern < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(RankedNonlinearPattern " << this->m_content << ")";
-}
-
 template < class SymbolType, class RankType >
 int RankedNonlinearPattern < SymbolType, RankType >::compare ( const RankedNonlinearPattern & other ) const {
 	auto first = ext::tie ( m_content, getAlphabet(), getSubtreeWildcard(), getNonlinearVariables() );
diff --git a/alib2data/src/tree/ranked/RankedPattern.h b/alib2data/src/tree/ranked/RankedPattern.h
index 0c10ef6b640b9d8ae3adfc459c05555e38245609..c3232d8c2e42807bf2a7ac4cf1ceb815de240e8f 100644
--- a/alib2data/src/tree/ranked/RankedPattern.h
+++ b/alib2data/src/tree/ranked/RankedPattern.h
@@ -34,18 +34,18 @@ class RankedPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/string>
 #include <alib/set>
 #include <alib/tree>
 #include <alib/iostream>
 #include <alib/algorithm>
-#include <sstream>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
 #include <tree/TreeException.h>
-#include <tree/TreeBase.h>
 #include <tree/common/TreeAuxiliary.h>
 
 #include <core/normalize.hpp>
@@ -72,7 +72,7 @@ class SubtreeWildcard;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class RankedPattern final : public TreeBase, public core::Components < RankedPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
+class RankedPattern final : public ext::CompareOperators < RankedPattern < SymbolType, RankType > >, public core::Components < RankedPattern < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet, common::ranked_symbol < SymbolType, RankType >, component::Value, SubtreeWildcard > {
 	/**
 	 * Natural representation of the pattern content.
 	 */
@@ -189,15 +189,6 @@ public:
 	 */
 	void setTree ( ext::tree < common::ranked_symbol < SymbolType, RankType > > pattern );
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -208,14 +199,28 @@ public:
 	int compare ( const RankedPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const RankedPattern & instance ) {
+		out << "(RankedPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * Nice printer of the tree natural representation
@@ -276,11 +281,6 @@ void RankedPattern < SymbolType, RankType >::setTree ( ext::tree < common::ranke
 	this->m_content = std::move ( pattern );
 }
 
-template < class SymbolType, class RankType >
-void RankedPattern < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(RankedPattern " << this->m_content << ")";
-}
-
 template < class SymbolType, class RankType >
 int RankedPattern < SymbolType, RankType >::compare ( const RankedPattern & other ) const {
 	auto first = ext::tie ( m_content, getAlphabet(), getSubtreeWildcard() );
diff --git a/alib2data/src/tree/ranked/RankedTree.h b/alib2data/src/tree/ranked/RankedTree.h
index 6d9c4ea14b5b844bf042f706ba86002a43a5fa38..9c5f437eb2e44426ba774aeb08d2b9acf88bd4bf 100644
--- a/alib2data/src/tree/ranked/RankedTree.h
+++ b/alib2data/src/tree/ranked/RankedTree.h
@@ -34,17 +34,18 @@ class RankedTree;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/string>
 #include <alib/set>
 #include <alib/tree>
 #include <alib/iostream>
 #include <alib/algorithm>
-#include <sstream>
+#include <alib/compare>
 
 #include <core/components.hpp>
 #include <common/ranked_symbol.hpp>
 
-#include <tree/TreeBase.h>
 #include <tree/TreeException.h>
 #include <tree/common/TreeAuxiliary.h>
 
@@ -72,7 +73,7 @@ class GeneralAlphabet;
  * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType, class RankType >
-class RankedTree final : public TreeBase, public core::Components < RankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
+class RankedTree final : public ext::CompareOperators < RankedTree < SymbolType, RankType > >, public core::Components < RankedTree < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
 	/**
 	 * Natural representation of the tree content.
 	 */
@@ -183,15 +184,6 @@ public:
 	 */
 	void setTree ( ext::tree < common::ranked_symbol < SymbolType, RankType > > tree );
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -202,14 +194,27 @@ public:
 	int compare ( const RankedTree & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const RankedTree & instance ) {
+		out << "(RankedTree ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * Hierarchical printer of the tree.
@@ -278,11 +283,6 @@ void RankedTree < SymbolType, RankType >::setTree ( ext::tree < common::ranked_s
 	this->m_content = std::move ( tree );
 }
 
-template < class SymbolType, class RankType >
-void RankedTree < SymbolType, RankType >::operator >>( std::ostream & out ) const {
-	out << "(RankedTree " << this->m_content << ")";
-}
-
 template < class SymbolType, class RankType >
 int RankedTree < SymbolType, RankType >::compare ( const RankedTree & other ) const {
 	auto first = ext::tie ( m_content, getAlphabet() );
diff --git a/alib2data/src/tree/unranked/PrefixBarTree.h b/alib2data/src/tree/unranked/PrefixBarTree.h
index be3b007b8c05602590dcee71e3db4dfb938f1d5a..388ede1dc1adcb3972565cd563c6234c8201b50a 100644
--- a/alib2data/src/tree/unranked/PrefixBarTree.h
+++ b/alib2data/src/tree/unranked/PrefixBarTree.h
@@ -34,6 +34,7 @@ class PrefixBarTree;
 } /* namespace tree */
 
 #include <sstream>
+
 #include <alib/algorithm>
 #include <alib/deque>
 #include <alib/set>
@@ -44,7 +45,6 @@ class PrefixBarTree;
 
 #include <alphabet/BarSymbol.h>
 
-#include <tree/TreeBase.h>
 #include <tree/TreeException.h>
 #include <tree/common/TreeAuxiliary.h>
 
@@ -75,7 +75,7 @@ class BarSymbol;
  * \tparam SymbolType used for the symbol of the alphabet
  */
 template < class SymbolType >
-class PrefixBarTree final : public TreeBase, public core::Components < PrefixBarTree < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, BarSymbol > {
+class PrefixBarTree final : public ext::CompareOperators < PrefixBarTree < SymbolType > >, public core::Components < PrefixBarTree < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, BarSymbol > {
 	/**
 	 * Linear representation of the tree content.
 	 */
@@ -194,15 +194,6 @@ public:
 	 */
 	bool isEmpty ( ) const;
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -213,14 +204,27 @@ public:
 	int compare ( const PrefixBarTree & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const PrefixBarTree & instance ) {
+		out << "(PrefixBarTree ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * \brief Creates a new instance of the string from a linear representation of a tree
@@ -302,16 +306,6 @@ int PrefixBarTree < SymbolType >::compare ( const PrefixBarTree & other ) const
 	return comp ( first, second );
 }
 
-template < class SymbolType >
-void PrefixBarTree < SymbolType >::operator >>( std::ostream & out ) const {
-	out << "(PrefixBarTree ";
-
-	for ( const SymbolType & symbol : this->m_Data )
-		out << symbol;
-
-	out << ")";
-}
-
 template < class SymbolType >
 PrefixBarTree < SymbolType >::operator std::string ( ) const {
 	std::stringstream ss;
diff --git a/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h b/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h
index 341d0120316c276fb6827d9deb69dfdd8a3dab40..e7b167aa3f5c00f5aedb44d011cc48e41bc9fb3a 100644
--- a/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h
+++ b/alib2data/src/tree/unranked/UnrankedNonlinearPattern.h
@@ -33,16 +33,17 @@ class UnrankedNonlinearPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/string>
 #include <alib/set>
 #include <alib/tree>
 #include <alib/iostream>
 #include <alib/algorithm>
-#include <sstream>
+#include <alib/compare>
 
 #include <core/components.hpp>
 
-#include <tree/TreeBase.h>
 #include <tree/TreeException.h>
 #include <tree/common/TreeAuxiliary.h>
 
@@ -71,7 +72,7 @@ class NonlinearAlphabet;
  * \tparam SymbolType used for the symbol of the alphabet
  */
 template < class SymbolType >
-class UnrankedNonlinearPattern final : public TreeBase, public core::Components < UnrankedNonlinearPattern < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, SymbolType, component::Value, SubtreeWildcard > {
+class UnrankedNonlinearPattern final : public ext::CompareOperators < UnrankedNonlinearPattern < SymbolType > > , public core::Components < UnrankedNonlinearPattern < SymbolType >, ext::set < SymbolType >, component::Set, std::tuple < GeneralAlphabet, NonlinearAlphabet >, SymbolType, component::Value, SubtreeWildcard > {
 	/**
 	 * Natural representation of the pattern content.
 	 */
@@ -208,15 +209,6 @@ public:
 	 */
 	void setTree ( ext::tree < SymbolType > pattern );
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -227,21 +219,36 @@ public:
 	int compare ( const UnrankedNonlinearPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const UnrankedNonlinearPattern & instance ) {
+		out << "(UnrankedNonlinearPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << "nonlinearVariables = " << instance.getNonlinearVariables ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * Nice printer of the tree natural representation
 	 *
-	 * \param os the output stream to print to
+	 * \param out the output stream to print to
 	 */
-	void nicePrint ( std::ostream & os ) const;
+	void nicePrint ( std::ostream & out ) const;
 };
 
 template < class SymbolType >
@@ -289,11 +296,6 @@ void UnrankedNonlinearPattern < SymbolType >::setTree ( ext::tree < SymbolType >
 	this->m_content = std::move ( pattern );
 }
 
-template < class SymbolType >
-void UnrankedNonlinearPattern < SymbolType >::operator >>( std::ostream & out ) const {
-	out << "(UnrankedNonlinearPattern " << this->m_content << ")";
-}
-
 template < class SymbolType >
 int UnrankedNonlinearPattern < SymbolType >::compare ( const UnrankedNonlinearPattern & other ) const {
 	auto first = ext::tie ( m_content, getAlphabet(), getSubtreeWildcard(), getNonlinearVariables() );
@@ -305,8 +307,8 @@ int UnrankedNonlinearPattern < SymbolType >::compare ( const UnrankedNonlinearPa
 }
 
 template < class SymbolType >
-void UnrankedNonlinearPattern < SymbolType >::nicePrint ( std::ostream & os ) const {
-	m_content.nicePrint ( os );
+void UnrankedNonlinearPattern < SymbolType >::nicePrint ( std::ostream & out ) const {
+	m_content.nicePrint ( out );
 }
 
 template < class SymbolType >
diff --git a/alib2data/src/tree/unranked/UnrankedPattern.h b/alib2data/src/tree/unranked/UnrankedPattern.h
index b69193da6efb43cac512a81cf695c63e6b9fd53d..5b4acf2c06b549f08be2735a4b285fc82519a17c 100644
--- a/alib2data/src/tree/unranked/UnrankedPattern.h
+++ b/alib2data/src/tree/unranked/UnrankedPattern.h
@@ -33,16 +33,16 @@ class UnrankedPattern;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/string>
 #include <alib/set>
 #include <alib/tree>
 #include <alib/iostream>
 #include <alib/algorithm>
-#include <sstream>
 
 #include <core/components.hpp>
 
-#include <tree/TreeBase.h>
 #include <tree/TreeException.h>
 #include <tree/common/TreeAuxiliary.h>
 
@@ -70,7 +70,7 @@ class SubtreeWildcard;
  * \tparam SymbolType used for the symbol of the alphabet
  */
 template < class SymbolType >
-class UnrankedPattern final : public TreeBase, public core::Components < UnrankedPattern < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, SubtreeWildcard > {
+class UnrankedPattern final : public ext::CompareOperators < UnrankedPattern < SymbolType > >, public core::Components < UnrankedPattern < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, SubtreeWildcard > {
 	/**
 	 * Natural representation of the pattern content.
 	 */
@@ -179,15 +179,6 @@ public:
 	 */
 	void setTree ( ext::tree < SymbolType > pattern );
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -198,14 +189,28 @@ public:
 	int compare ( const UnrankedPattern & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const UnrankedPattern & instance ) {
+		out << "(UnrankedPattern ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << "subtreeWildcard = " << instance.getSubtreeWildcard ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * Nice printer of the tree natural representation
@@ -256,11 +261,6 @@ void UnrankedPattern < SymbolType >::setTree ( ext::tree < SymbolType > pattern
 	this->m_content = std::move ( pattern );
 }
 
-template < class SymbolType >
-void UnrankedPattern < SymbolType >::operator >>( std::ostream & out ) const {
-	out << "(UnrankedPattern " << this->m_content << ")";
-}
-
 template < class SymbolType >
 int UnrankedPattern < SymbolType >::compare ( const UnrankedPattern & other ) const {
 	auto first = ext::tie ( m_content, getAlphabet(), getSubtreeWildcard() );
diff --git a/alib2data/src/tree/unranked/UnrankedTree.h b/alib2data/src/tree/unranked/UnrankedTree.h
index 342f3b8904e84dbefa51031ddf25e57193023c86..8bb9312860be2043c00a737d0fe380fc7cfd1c23 100644
--- a/alib2data/src/tree/unranked/UnrankedTree.h
+++ b/alib2data/src/tree/unranked/UnrankedTree.h
@@ -33,16 +33,17 @@ class UnrankedTree;
 
 } /* namespace tree */
 
+#include <sstream>
+
 #include <alib/string>
 #include <alib/set>
 #include <alib/tree>
 #include <alib/iostream>
 #include <alib/algorithm>
-#include <sstream>
+#include <alib/compare>
 
 #include <core/components.hpp>
 
-#include <tree/TreeBase.h>
 #include <tree/TreeException.h>
 #include <tree/common/TreeAuxiliary.h>
 
@@ -68,7 +69,7 @@ class GeneralAlphabet;
  * \tparam SymbolType used for the symbol of the alphabet
  */
 template < class SymbolType >
-class UnrankedTree final : public TreeBase, public core::Components < UnrankedTree < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > {
+class UnrankedTree final : public ext::CompareOperators < UnrankedTree < SymbolType > >, public core::Components < UnrankedTree < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet > {
 	/**
 	 * Natural representation of the pattern content.
 	 */
@@ -157,15 +158,6 @@ public:
 	 */
 	void setTree ( ext::tree < SymbolType > data );
 
-	/**
-	 * @copydoc base::CommonBase < TreeBase >::compare ( const TreeBase & )
-	 */
-	virtual int compare ( const TreeBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
@@ -176,14 +168,27 @@ public:
 	int compare ( const UnrankedTree & other ) const;
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator >> ( std::ostream & )
+	 * Print this object as raw representation to ostream.
+	 *
+	 * \param out ostream where to print
+	 * \param instance object to print
+	 *
+	 * \returns modified output stream
 	 */
-	virtual void operator >>( std::ostream & out ) const override;
+	friend std::ostream & operator << ( std::ostream & out, const UnrankedTree & instance ) {
+		out << "(UnrankedTree ";
+		out << "alphabet = " << instance.getAlphabet ( );
+		out << "content = " << instance.getContent ( );
+		out << ")";
+		return out;
+	}
 
 	/**
-	 * @copydoc base::CommonBase < TreeBase >::operator std::string ( )
+	 * Casts this instance to as compact as possible string representation.
+	 *
+	 * \returns string representation of the object
 	 */
-	virtual explicit operator std::string ( ) const override;
+	explicit operator std::string ( ) const;
 
 	/**
 	 * Nice printer of the tree natural representation
@@ -234,11 +239,6 @@ void UnrankedTree < SymbolType >::setTree ( ext::tree < SymbolType > data ) {
 	this->m_content = std::move ( data );
 }
 
-template < class SymbolType >
-void UnrankedTree < SymbolType >::operator >>( std::ostream & out ) const {
-	out << "(UnrankedTree " << this->m_content << ")";
-}
-
 template < class SymbolType >
 int UnrankedTree < SymbolType >::compare ( const UnrankedTree & other ) const {
 	auto first = ext::tie ( m_content, getAlphabet() );