Improvements to cd and selectorFromDOM to support html traversal