Creating a Custom Field Type with nested Fields
I don't believe you need a new custom field type for this. What your describing has been accomplished quite well already by the Neo plugin...


  https://github.com/benjamminf/craft-neo


Additionally, the Super Table plugin has similar capabilities...


  https://github.com/engram-design/SuperTable