Fixes memoization to reuse the visited node's tree. Fixes #9