Added a node level detection algorithm