Add comprehensive unit tests to verify the fix prevents AttributeError when accessing non-existent nodes.