Flatten nested subqueries

e.g. `SELECT FROM (SELECT FROM (SELECT FROM table))` flattens into one select