Thanks so much for replying.
Actually what i want to do is extend the Entry Class to add a method that can find any entry it links to matches a specific name.
For example :
A entry named A1 link to B1 and B2
then B1 link to C1 and C2
so this is like a binary tree structure with 3 layers from root A1 to leaf C1 or C2.
Then, since every node is Entry type, I want to extend the Entry Class to add a extra method "sub" to search if any child node matches the required name.
eg:
A1.sub("B1") should return B1 note as an entry type because B1's field "name" is "B1"
or in another word:
A1.field("link").find(x=>x.field("name")=="B1")
similarly:
A1.sub("B1").sub("C2") should return C2 as an entry type
I have successfully wrote the sub as a global function by following definitions:
(see picture below)

it can be called like sub(A1,"B1") and works fine.
but what I actually wanna do is to add it into the Entry class as a method so i can write a clear and beautiful chain as A1.sub("B1").sub("C2").sub("D3)...... instead of ugly and hard to read nested function like sub(sub(sub(A1,"B1"),"C2"),D3)......