compares structure recursively