extract partial tree should take either tree or string representation