Printing out a binary tree level by level
I got the following output:


Level 1: 5   Level 2: 2  8   Level 4: 4  7  10   Level 3: 1  3  6  9



Printing the layers in a non-deterministic order is probably undesirable behaviour.  You used an unordered_map, which guarantees the order of neither its keys nor its values.  To impose order on the values (the nodes of each level), you store a vector in the map, which complicates the data structure.

The traditional way to do a breadth-first traversal of a tree is to use a queue, and to work iteratively on elements of the queue rather than recursively on elements of the tree.  Not only is this a less complex data structure than an unordered map of ints to vectors of nodes, it also stores nodes from no more than two levels of the tree at a time, rather than all nodes of the tree at once.

#include &lt;queue&gt;
#include &lt;utility&gt;   // for std::pair

template &lt;typename T&gt;
void printBinaryTree(const Node&lt;T&gt; *n) {
    if (nullptr == n) {
        return;
    }
    int level = 0;

    // Use a queue for breadth-first traversal of the tree.  The pair is
    // to keep track of the depth of each node.  (Depth of root node is 1.)
    typedef std::pair&lt;const Node&lt;T&gt;*,int&gt; node_level;
    std::queue&lt;node_level&gt; q;
    q.push(node_level(n, 1));

    while (!q.empty()) {
        node_level nl = q.front();
        q.pop();
        if (nullptr != (n = nl.first)) {
            if (level != nl.second) {
                std::cout &lt;&lt; " Level " &lt;&lt; nl.second &lt;&lt; ": ";
                level = nl.second;
            }
            std::cout &lt;&lt; n-&gt;data &lt;&lt; ' ';
            q.push(node_level(n-&gt;left,  1 + level));
            q.push(node_level(n-&gt;right, 1 + level));
        }
    }
    std::cout &lt;&lt; std::endl;
}


As a final touch, pay attention to the const-correctness of the function's parameter.