move try/catch out of keysForTree(), fix #9