How to add a custom widget to a node creation form Drupal 6
I'd take a look at two modules, the base level Hierarchical Select module and its Hierarchical Select Node Reference submodule.  The second module allows you to create "on the fly" a node referenced by the parent node being created and may do what you need without custom coding on your part.