How to get all children with parent class

Thank you very much, but is there some more automatic way? I want to make it more dynamic so when i add some child later it’s added automatically to the array.