Hierarchical product graphs and their prime factorization