Although the parent of an alias is its (outline) parent, as the image shows, it is not always interpreted as such. In addition, queries like inside() and descendedFrom() find aliases in 'other' containers besides their original's because the original note lies within scope of the query.
Note that use of the 'parent' designator can be used to filter queries rendering apparent false positives. The
$Name(parent) for alias and original will differ unless both are in the same container - as is often the case when an alias is freshly created and not yet moved to its intended location. Be aware though that alias and original share the same $DisplayExpression so this is not a good a good way to investigate the difference.
All children of an agent are aliases regardless of whether they point to an original or an alias.
Changes in v5.0.2 and v5.1.0 to the way agents function will make queries like inside() and descendedFrom() function more accurately when looking for both original and/or existing aliases. At the same time, the addition of the $IsAlias attribute also helps.
$IsAlias cannot be used on its own, can help find only original notes:
inside(Some Container) & !$IsAlias
To find aliases as opposed to originals, it may be insufficient to use the reverse:
inside(Some Container) & $IsAlias
Why? Because an agent's children are also aliases, although not user-created ones. In order to filter out aliases within agents an extra query term is required:
inside(someContainer) & $IsAlias & !$AgentQuery(parent)
As agents de-dupe listings, the above methods can't be used to locate multiple aliases of the same note. However, it is possible to locate their containers - as long as the latter are themselves not all named the same. Use:
!$AgentQuery & any(child,$IsAlias)
Clause one discards any containers that are agents (because they will have a query value). The second clause matches any container where one or more children are aliases. To filter this for just aliases of a known note title, try:
!$AgentQuery & any(children,$IsAlias) & any(children,$Name=="Other Attribute types")
There is no 'IsAgent' test but only agent will have a value for $AgentQuery so it works in this context. Whilst it is possible to make an agent and not give it a query, such an agent cannot have any children (no query to match against) and so wouldn't affect the above query.
It may be easier to use find() for tracking down aliases.