Move graph defs/impls to a submodule. Add a tree module