recursively restructure expressions