My table had a bunch more fields to allow for more versitile menu structure (open icon, close icon, font size, font color etc) but basic functionality is accomplished by this:
autoid | entry | url | parent
with regards to the presence of $item in $open:
if you read through my post again, hopefully, you'll notice that $item is not placed in $open unless it is not already in there. Think of $item as a trigger, not as a result. $open is the result.
$open is the list of currently open objects, so if you click on an unopened object, $item will contain the autoid of that UNOPENED object but will be added to $open. If $open contains $item, then that object is already expanded and you need to send $item to the function to close all children (my function that deleted all the children/subchildren/subsubchildren/etc/etc was called "infanticide")
Don't beat yourself up over this too much. My boss (rated hardware/networking/software/programming/electronics God Level 10+) wrote an original script for this that had some severe bugs. Took me a week or two to iron out myself. My "ironing" process basically involved a complete re-write. Don't be afraid to start over.
I'd post my code, but it technically doesn't belong to me anymore.
-Bennish (of or relating to Ben)