be more helpful when a user is confused and doing weird things

this cost me quite some time to figure out why i got strange errors about `spl_object_hash` expecting an object. these checks improve the error messages. also adding some more sanity checks on child and children that we only had for references until now.