Pass tree to javascript