Check to see if content exists; if not, create it I have two node types that are related by a node reference. Essentially, content type A is a container, and content type B is an item. For illustration sake, I'll call content A Box and content B Item. the Item has a number of taxonomy terms that are shared with Box. Again for illustration sake lets call them color and size. What I'm trying to do is set up a rule that does the following: 


On Creation of an Item ( actually before the content is save) check to see if there is a Box that shares both the color and the size of the item.
If one exists, assign the new item to that box (via node reference).
If one does not exist create the box, then assign the new item to that box.


I'm new to the Rules module, and although it seems really powerful, I'm just not sure that this particular use case is possible. The part that I'm most unsure about is how to check if the box with certain terms exists.
I think doing this with Rules alone, will work if you have a very limited set of nodes. Once you pass 100 or so, then the overhead of all the object wrappers will soon force you to give PHP gigabytes of RAM instead of megabytes, and then set your servers CPU aflame.

I belive an approach that integrates Rules with Views bulk operations however, could do this neatly for you.
I have not attemped anything similar myself, but a VBO should be able to query the database for the node, and then if it exists, return it to Rules.

The code approach would be to implement hook_node_presave, query the database with an EntityFieldQuery for a Box node with the right terms, and assign the reference.