building hierarchical structure of year and month