Add bidiretional association for tree nodes and fix a bug