[DD-734] re-write GDMModel#toJSON to be able to process hierarchical entities