Hi Chetan,
Use a common Number for all the entities as an attribute starting from 1.
if common entity has that number in its attribute then change required attributes from respective sub entities other wise create common entity and commit. Make sure every time you create an object increment sub entity attribute by 1 and copy the same incremented number to the common entity attribute.
There could be other ways to do as well but this could be one solution.
Regards,
Cyril