Question: I was wondering if there is a way to merge multiple layers. I actually would like to merge all layers in the registry programmatically, all of them are point layers and have the same fields.
I have thinking I might copy all features from all layers and paste them into a new vector layer... but I believe there should be an easier option. What do you think??
Would that be possible?

Answer: 
you can call a process like the merge function programmatically in python: 

```
import processing
processing.runalg('qgis:mergevectorlayers', layer1, layer2, savename)

```
I solved it today. You might understand how to activate each layers.

But here is what I did:

```
from qgis.gui import QgsLayerTreeView
from qgis.gui import QgisInterface
from qgis.core import QgsLayerTree
from qgis.core import QgsLayerTreeNode
from qgis.core import QgsProject
from qgis.gui import *
import processing
root = QgsProject.instance().layerTreeRoot()
iface.layerTreeView().setCurrentLayer(None) #Deselect what u previously selected one
for child in root.children():
#print ("- group: " + child.name())
if child.name() == "산정천": #to check subgroups within test group
    for subChild in child.children():
        subChild.name()
        if subChild.name() == "기초지도":

            for lastChild in subChild.children():
                lastChild.name()
                for EndChild in lastChild.children():
                    if isinstance(lastChild, QgsLayerTreeGroup):
                        EndChild.name()
                        #print(EndChild.name())
                        if EndChild.name() == "A0010000":

                            iface.layerTreeView().setSelectionMode( QAbstractItemView.MultiSelection )
                            iface.setActiveLayer(EndChild.layer())
List = iface.layerTreeView().selectedLayers()
print(List)
processing.runAndLoadResults("native:mergevectorlayers",
{'LAYERS':List,'CRS':QgsCoordinateReferenceSystem('EPSG:5186'),
'OUTPUT':'TEMPORARY_OUTPUT'})
iface.layerTreeView().setSelectionMode( QAbstractItemView.ExtendedSelection )

```

I made one for selecting every "A0010000" named layers in "산정천" root group
and processing merge at temporary output.
This is working more than 3.x version I guess (3.22 for me).
This is my first code from my life, so if you need explanation I would be glad to help you.