Treant.js
function( node, level ) {
            node.leftNeighborId = this.lastNodeOnLevel[level];
            if ( node.leftNeighborId ) {
                node.leftNeighbor().rightNeighborId = node.id;
            }
            this.lastNodeOnLevel[level] = node.id;
            return this;
        }
function( node, level ) {
            node.leftNeighborId = this.lastNodeOnLevel[level];
            if ( node.leftNeighborId ) {
                node.leftNeighbor().rightNeighborId = node.id;
            }
            this.lastNodeOnLevel[level] = node.id;
            return this;
        }
function ( node , level ) { node . leftNeighborId = this . lastNodeOnLevel [ level ] ; if ( node . leftNeighborId ) { node . leftNeighbor ( ) . rightNeighborId = node . id ; } this . lastNodeOnLevel [ level ] = node . id ; return this ; }
Algorithm works from left to right, so previous processed node will be left neighbour of the next node
@param {TreeNode} node
@param {number} level
@returns {Tree}
Algorithm works from left to right so previous processed node will be left neighbour of the next node