generalize Document::createPath() to support different types