Fixed the function to abstract common logic to find the suitable node including the node itself.