Add support for automatic extraction

- Prompted a major refactor that makes the transformation more robust by using symbols for comparison instead of trees.