Added a fix to handle when no state are found for the current parent
Added debug statements
Removed uneeded code