Converted getNodesByType to walk the hierarchy of nested nodes.