Question: I have table with child and parent hierarchy within same table.
I have column to identify the parent of the respective node.
Records like

```
Id  name  Parent
1    ABC   Null
2    PQR   1
3    DEF   Null
4    LMN   Null
5    OPQ   Null
6    JKL    2
7    TUY    4

CREATE TABLE #Temp
(
   Id INT,
   Name varchar(3),
   Parent INT
)

INSERT INTO #Temp VALUES (1,’ABC’,Null)
INSERT INTO #Temp VALUES (2,’PQR’, 1)
INSERT INTO #Temp VALUES (3,’DEF’, Null)
INSERT INTO #Temp VALUES (4,’LMN’, Null)
INSERT INTO #Temp VALUES (5,’OPQ’, Null)
INSERT INTO #Temp VALUES (6,’JKL’, 2)
INSERT INTO #Temp VALUES (7,’TUY’, 4)

```

How to write query to find out parent who have child and id of child?
More-over one query to find the the children who dont have parent ?

Answer: 
According to [the paper about RERAN tool](http://www.lorenzobgomez.com/publications/icse13gomez.pdf) one can record and replay very low-level UI events using the `getevent` and `sendevent` tools, both available in Android SDK. 

The [RERAN tool](http://www.androidreran.com/) can do the job, but it requires root and it is unclear if it can work on Android newer than 2.3.4. RERAN doesn't use `sendevent` because it has small lag that makes it unable to faithfully replay the event stream. Because the tool uses its custom solution instead of `sendevent`, it requires for the phone to be rooted.
The RERAN tool is outdated and it needs root to record from a device and replay back **only** to this particular device with the particular Android version.

Check out appetizer-toolkit. It works with non-root devices with ADB debugging. And it can replay to devices with the same aspect ratio as the recording device.
<https://github.com/appetizerio/appetizer-toolkit>