Enforce balanced () and [] in tree parser