Builds depdency trees from reference tags in javascript