refactored getChildren function up to first level