Change the logic of Menu

I have fixed the bug (the duplication of childnodes). Please test it and notify me if anything goes wrong again.