fixed bug in open_all function

check if node is leaf instead of is loaded to make recursive calls