Refactor nodeToHTML() into multiple, smaller functions.