diff --git a/alib2str/src/tree/TreeToStringComposer.cpp b/alib2str/src/tree/TreeToStringComposer.cpp
index f2ee31a8b4499e990102b04e46304ded2827c251..382a732e04112230a8f4da72d6ee450105dff2d7 100644
--- a/alib2str/src/tree/TreeToStringComposer.cpp
+++ b/alib2str/src/tree/TreeToStringComposer.cpp
@@ -6,11 +6,47 @@
  */
 
 #include "TreeToStringComposer.h"
+#include <tree/ranked/RankedTree.h>
+#include <tree/unranked/UnrankedTree.h>
 
 #include "../StringApi.hpp"
 
 namespace tree {
 
+void TreeToStringComposer::compose ( std::ostream & out, const RankedTree & tree ) {
+	compose ( out, tree.getRoot ( ) );
+}
+
+TreeToStringComposer::RegistratorWrapper < void, RankedTree > StringToStringComposerRankedTree = TreeToStringComposer::RegistratorWrapper < void, RankedTree > ( TreeToStringComposer::getInstance ( ), TreeToStringComposer::compose );
+
+void TreeToStringComposer::compose ( std::ostream & out, const RankedNode & node ) {
+	alib::stringApi < alphabet::Symbol >::compose ( out, node.getSymbol ( ).getSymbol ( ) );
+
+	out << std::utos ( node.getSymbol ( ).getRank ( ).getData ( ) );
+
+	for ( const RankedNode * node : node.getChildren ( ) ) {
+		out << " ";
+		compose ( out, * node );
+	}
+}
+
+void TreeToStringComposer::compose ( std::ostream & out, const UnrankedTree & tree ) {
+	compose ( out, tree.getRoot ( ) );
+}
+
+TreeToStringComposer::RegistratorWrapper < void, UnrankedTree > StringToStringComposerUnrankedTree = TreeToStringComposer::RegistratorWrapper < void, UnrankedTree > ( TreeToStringComposer::getInstance ( ), TreeToStringComposer::compose );
+
+void TreeToStringComposer::compose ( std::ostream & out, const UnrankedNode & node ) {
+	alib::stringApi < alphabet::Symbol >::compose ( out, node.getSymbol ( ) );
+
+	for ( const UnrankedNode * node : node.getChildren ( ) ) {
+		out << " ";
+		compose ( out, * node );
+	}
+
+	out << " |";
+}
+
 void TreeToStringComposer::compose ( std::ostream & out, const Tree & tree ) {
 	getInstance ( ).dispatch ( out, tree.getData ( ) );
 }
diff --git a/alib2str/src/tree/TreeToStringComposer.h b/alib2str/src/tree/TreeToStringComposer.h
index 5afbc0f055a1db23450653160e532f2eabac393d..12cc21ab18f9c00b7f1bd91b5909d1529cb75936 100644
--- a/alib2str/src/tree/TreeToStringComposer.h
+++ b/alib2str/src/tree/TreeToStringComposer.h
@@ -19,7 +19,13 @@ namespace tree {
  * This class contains methods to print XML representation of tree to the output stream.
  */
 class TreeToStringComposer : public std::SingleDispatchFirstStaticParam < void, std::ostream &, TreeBase > {
+	static void compose ( std::ostream &, const RankedNode & tree );
+	static void compose ( std::ostream &, const UnrankedNode & tree );
+
 public:
+	static void compose ( std::ostream &, const RankedTree & tree );
+	static void compose ( std::ostream &, const UnrankedTree & tree );
+
 	/**
 	 * Prints XML representation of String to the output stream.
 	 * @param tree String to print
diff --git a/alib2str/test-src/tree/TreeTest.cpp b/alib2str/test-src/tree/TreeTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..837318fe07e42a192761a707b710f9f80a8f3540
--- /dev/null
+++ b/alib2str/test-src/tree/TreeTest.cpp
@@ -0,0 +1,76 @@
+#include <list>
+#include "TreeTest.h"
+
+#include "sax/SaxParseInterface.h"
+#include "sax/SaxComposeInterface.h"
+
+#include "tree/Tree.h"
+
+#include "factory/StringDataFactory.hpp"
+
+#include "alphabet/Symbol.h"
+#include "alphabet/LabeledSymbol.h"
+#include "alphabet/BlankSymbol.h"
+
+#define CPPUNIT_IMPLY( x, y )    CPPUNIT_ASSERT ( !( x ) || ( y ) )
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( TreeTest, "tree" );
+CPPUNIT_TEST_SUITE_REGISTRATION ( TreeTest );
+
+void TreeTest::setUp ( ) {
+}
+
+void TreeTest::tearDown ( ) {
+}
+
+void TreeTest::testEqual ( ) {
+	{
+		std::string input = "a0";
+		tree::Tree tree = alib::StringDataFactory::fromString < tree::Tree > ( input );
+
+		std::string output = alib::StringDataFactory::toString ( tree );
+
+		CPPUNIT_ASSERT ( input == output );
+
+		tree::Tree tree2 = alib::StringDataFactory::fromString < tree::Tree > ( output );
+
+		CPPUNIT_ASSERT ( tree == tree2 );
+	}
+	{
+		std::string input = "a |";
+		tree::Tree tree = alib::StringDataFactory::fromString < tree::Tree > ( input );
+
+		std::string output = alib::StringDataFactory::toString ( tree );
+
+		CPPUNIT_ASSERT ( input == output );
+
+		tree::Tree tree2 = alib::StringDataFactory::fromString < tree::Tree > ( output );
+
+		CPPUNIT_ASSERT ( tree == tree2 );
+	}
+	{
+		std::string input = "a2 a0 a1 a0";
+		tree::Tree tree = alib::StringDataFactory::fromString < tree::Tree > ( input );
+
+		std::string output = alib::StringDataFactory::toString ( tree );
+
+		CPPUNIT_ASSERT ( input == output );
+
+		tree::Tree tree2 = alib::StringDataFactory::fromString < tree::Tree > ( output );
+
+		CPPUNIT_ASSERT ( tree == tree2 );
+	}
+
+	{
+		std::string input = "a a | a a | | |";
+		tree::Tree tree = alib::StringDataFactory::fromString < tree::Tree > ( input );
+
+		std::string output = alib::StringDataFactory::toString ( tree );
+
+		CPPUNIT_ASSERT ( input == output );
+
+		tree::Tree tree2 = alib::StringDataFactory::fromString < tree::Tree > ( output );
+
+		CPPUNIT_ASSERT ( tree == tree2 );
+	}
+}
diff --git a/alib2str/test-src/tree/TreeTest.h b/alib2str/test-src/tree/TreeTest.h
new file mode 100644
index 0000000000000000000000000000000000000000..96e21197ccba14bb349d6501665b9cedf1af5326
--- /dev/null
+++ b/alib2str/test-src/tree/TreeTest.h
@@ -0,0 +1,18 @@
+#ifndef TREE_TEST_H_
+#define TREE_TEST_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class TreeTest : public CppUnit::TestFixture {
+	CPPUNIT_TEST_SUITE ( TreeTest );
+	CPPUNIT_TEST ( testEqual );
+	CPPUNIT_TEST_SUITE_END ( );
+
+public:
+	void setUp ( );
+	void tearDown ( );
+
+	void testEqual ( );
+};
+
+#endif // TREE_TEST_H_