Update index.js

tree flatten fix