wrap document where needed
use 'unwrap' instead of derefing node/impl directly