Binary decision diagram, newbie code