flat database tree for mongodb queries